Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix up paths to be filesystem independant #3

Open
wants to merge 1 commit into
base: develop-r4b
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions Test.Hl7.Fhir.MappingLanguage/SDOH_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Hl7.Fhir.Specification;
using Hl7.Fhir.Specification.Source;
using Hl7.FhirPath;
using System.IO;
using Microsoft.VisualStudio.TestPlatform.Utilities;
using Microsoft.VisualStudio.TestTools.UnitTesting;

Expand All @@ -20,7 +21,7 @@ public class SDOH_Tests

private StructureMap GetFromMapFile(string relpath)
{
var resourceMap = System.IO.File.ReadAllText($"{pathSDOHClinicalCare}{relpath}");
var resourceMap = System.IO.File.ReadAllText(Path.Combine(pathSDOHClinicalCare, relpath));
var parser = new StructureMapUtilitiesParse();
var sm = parser.parse(resourceMap, null);
return sm;
Expand All @@ -29,14 +30,14 @@ private StructureMap GetFromMapFile(string relpath)
private T GetFhirResourceFromJson<T>(string relpath)
where T : Resource, new()
{
var resourceJson = System.IO.File.ReadAllText($"{pathSDOHClinicalCare}{relpath}");
var resourceJson = System.IO.File.ReadAllText(Path.Combine(pathSDOHClinicalCare, relpath));
var rp = new FhirJsonParser();
return rp.Parse<T>(resourceJson);
}
private T GetFhirResourceFromXml<T>(string relpath)
where T : Resource, new()
{
var resourceJson = System.IO.File.ReadAllText($"{pathSDOHClinicalCare}{relpath}");
var resourceJson = System.IO.File.ReadAllText(Path.Combine(pathSDOHClinicalCare, relpath));
var rp = new FhirXmlParser();
return rp.Parse<T>(resourceJson);
}
Expand All @@ -49,15 +50,15 @@ private CachedResolver GetSource()
};
return new CachedResolver(
new MultiResolver(
new DirectorySource($"{pathSDOHClinicalCare}\\output", ds),
new DirectorySource(Path.Combine(pathSDOHClinicalCare, "output"), ds),
ZipSource.CreateValidationSource()));
}

[TestMethod]
public void TransformPrapareMap()
{
var sm = GetFromMapFile(@"\input\map-source\SDOHCC-PRAPARE-Map.map");
var qr = GetFhirResourceFromXml<QuestionnaireResponse>(@"\input\resources\questionnaireresponse\SDOHCC-QuestionnaireResponsePRAPAREExample.xml");
var sm = GetFromMapFile(Path.Combine("input", "map-source", "SDOHCC-PRAPARE-Map.map"));
var qr = GetFhirResourceFromXml<QuestionnaireResponse>(Path.Combine("input", "resources", "questionnaireresponse", "SDOHCC-QuestionnaireResponsePRAPAREExample.xml"));

var source = GetSource();
var worker = new TestWorker(source);
Expand All @@ -83,8 +84,8 @@ public void TransformPrapareMap()
[TestMethod]
public void TransformVitalsMap()
{
var sm = GetFromMapFile(@"\input\map-source\SDOHCC-Hunger-Vital-Sign-Map.map");
var qr = GetFhirResourceFromXml<QuestionnaireResponse>(@"\input\resources\questionnaireresponse\SDOHCC-QuestionnaireResponseHungerVitalSignExample.xml");
var sm = GetFromMapFile(Path.Combine("input", "map-source", "SDOHCC-Hunger-Vital-Sign-Map.map"));
var qr = GetFhirResourceFromXml<QuestionnaireResponse>(Path.Combine("input", "resources", "questionnaireresponse", "SDOHCC-QuestionnaireResponseHungerVitalSignExample.xml"));

var source = GetSource();
var worker = new TestWorker(source);
Expand All @@ -106,4 +107,4 @@ public void TransformVitalsMap()

}
}
}
}