Skip to content

Commit

Permalink
Merge pull request #1175 from FirelyTeam/bugfix/1174-typedelement-sou…
Browse files Browse the repository at this point in the history
…rcenode-adapter-resourcetypesupplier

Adjust TypedElementToSourceNodeAdapterTests
  • Loading branch information
marcovisserFurore authored Feb 5, 2020
2 parents 17031da + cb7f0d1 commit add8073
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
2 changes: 1 addition & 1 deletion common
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ public void AnnotationsTest()

var result2 = sourceNode.Annotation<IResourceTypeSupplier>();
Assert.IsNotNull(result2);
Assert.AreEqual("PocoElementNode", result2.GetType().Name); // I use the classname here, because PocoElementNode is internal in Hl7.Fhir.Core
Assert.AreSame(typedElement, result2);
Assert.AreEqual("TypedElementToSourceNodeAdapter", result2.GetType().Name); // I use the classname here, because PocoElementNode is internal in Hl7.Fhir.Core
Assert.AreSame(sourceNode, result2);
}

[TestMethod]
Expand All @@ -51,7 +51,27 @@ public void AnnotationsFromParsingTest()

var result3 = sourceNode.Annotation<IResourceTypeSupplier>();
Assert.IsNotNull(result3);
Assert.AreEqual(typeof(FhirJsonNode), result3.GetType());
Assert.AreEqual(typeof(TypedElementToSourceNodeAdapter), result3.GetType());
}

[TestMethod]
public void SourceNodeFromElementNodeReturnsResourceTypeSupplier()
{
var _sdsProvider = new PocoStructureDefinitionSummaryProvider();
var patientJson = "{\"resourceType\":\"Patient\", \"active\":\"true\"}";
var patientNode = FhirJsonNode.Parse(patientJson);
var typedPatient = patientNode.ToTypedElement(_sdsProvider, "Patient");

var elementNode = ElementNode.FromElement(typedPatient);
var adapter = elementNode.ToSourceNode();

Assert.AreEqual(typeof(TypedElementToSourceNodeAdapter), adapter.GetType(), "ISourceNode is provided by TypedElementToSourceNodeAdapter");

var result = adapter.Annotation<IResourceTypeSupplier>();
Assert.IsNotNull(result);
Assert.AreEqual(typeof(TypedElementToSourceNodeAdapter), result.GetType());
Assert.AreEqual("Patient", adapter.GetResourceTypeIndicator());
Assert.AreSame(adapter, result);
}
}
}

0 comments on commit add8073

Please sign in to comment.