-
Notifications
You must be signed in to change notification settings - Fork 343
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2841 from FirelyTeam/feature/FP-extensions-defaul…
…t-context %resource and %rootResource in default context
- Loading branch information
Showing
9 changed files
with
120 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/Hl7.FhirPath.R4.Tests/PocoTests/FhirPathContextTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using FluentAssertions; | ||
using Hl7.Fhir.ElementModel; | ||
using Hl7.Fhir.FhirPath; | ||
using Hl7.Fhir.Model; | ||
using Hl7.Fhir.Serialization; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using System.IO; | ||
using System.Linq; | ||
|
||
namespace Hl7.FhirPath.R4.Tests.PocoTests; | ||
|
||
[TestClass] | ||
public class FhirPathContextTests | ||
{ | ||
ScopedNode _bundle; | ||
|
||
[TestInitialize] | ||
public void SetupSource() | ||
{ | ||
var bundleXml = File.ReadAllText(Path.Combine("TestData", "bundle-contained-references.xml")); | ||
|
||
_bundle = ((new FhirXmlParser()).Parse<Bundle>(bundleXml)).ToTypedElement().ToScopedNode(); | ||
} | ||
|
||
[TestMethod] | ||
public void TestFhirEvaluationContext() | ||
{ | ||
_bundle.IsTrue("entry[2].resource.contained[0].select(%resource) = %resource"); // should stay the same | ||
_bundle.IsTrue("%rootResource = Bundle.entry[2].resource.contained[0].select(%rootResource)"); // should stay the same | ||
|
||
var elemInContainedResource = _bundle.Children("entry").Skip(2).First().Children("resource").First().Children("contained").First().Children("id").First().ToScopedNode(); | ||
elemInContainedResource.IsTrue("%rootResource != %resource"); // should be true | ||
elemInContainedResource.Select("%rootResource").Should().BeEquivalentTo(_bundle.Select("entry[2].resource")); | ||
|
||
var elemInDomainResource = _bundle.Children("entry").Skip(2).First().Children("resource").First().Children("id").First().ToScopedNode(); | ||
elemInDomainResource.IsTrue("%rootResource = %resource"); | ||
elemInDomainResource.Select("%rootResource").Should().BeEquivalentTo(_bundle.Select("entry[2].resource")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters