Skip to content

Commit

Permalink
improved unit test and documented exceptions.
Browse files Browse the repository at this point in the history
  • Loading branch information
mmsmits committed Oct 28, 2024
1 parent d3924e2 commit a061001
Showing 1 changed file with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ public void PocoAndSdSummaryProvidersShouldBeEqual()

foreach (var item in ModelInfo.OpenTypes)
{
if (item == typeof(Canonical) || item == typeof(DataRequirement) || item == typeof(Signature) || item == typeof(Timing) || item == typeof(FhirUrl) || item == typeof(UsageContext)) continue;
if (item == typeof(Canonical) //New datatype in R4, so this will fail for STU3
|| item == typeof(FhirUrl)) //New datatype in R4, so this will fail for STU3
continue;
var canonicalResource = ModelInfo.CanonicalUriForFhirCoreType(item);
var pocoSummary = pocoSdProvider.Provide(canonicalResource);
var sdSummary = sdProvide.Provide(canonicalResource);
Expand Down Expand Up @@ -62,7 +64,9 @@ private static void areEqual(IStructureDefinitionSummary left, IStructureDefinit
context = string.Join('.', workStack.Reverse());
try
{
left.IsAbstract.Should().Be(right.IsAbstract, context + ": Abstract differs");
if (context != "DataRequirement.codeFilter.Element" && context != "DataRequirement.dateFilter.Element" && context != "Timing.repeat.Element") // Issue in the STU3 StructureDefinition for DataRequirement.codeFilter, DataRequirement.dateFilter, and Timing.repeat where the type is set to "Element" but not to "BackboneElement".
left.IsAbstract.Should().Be(right.IsAbstract, context + ": Abstract differs");

left.IsResource.Should().Be(right.IsResource, context + ": IsResource differs");
left.TypeName.Should().Be(right.TypeName, context + ": TypeName differs");
areEqual(left.GetElements(), right.GetElements(), workStack);
Expand Down Expand Up @@ -135,7 +139,10 @@ private static void areEqual(IElementDefinitionSummary left, IElementDefinitionS
left.IsChoiceElement.Should().Be(right.IsChoiceElement, context + ": IsChoiceElement differs");
left.IsCollection.Should().Be(right.IsCollection, context + ": IsCollection differs");

if (context != "Binary.content") //because of issue #2821
if (context != "Binary.content" //because of issue #2821
&& context != "Signature.type" //This was required in STU3, but not in R4+, so kept it optional when moving to base.
&& context != "Signature.when" //This was required in STU3, but not in R4+, so kept it optional when moving to base.
&& !context.StartsWith("Signature.who")) //This was required in STU3, but not in R4+, so kept it optional when moving to base.
left.IsRequired.Should().Be(right.IsRequired, context + ": IsRequired differs");

left.IsResource.Should().Be(right.IsResource, context + ": IsResource differs");
Expand Down Expand Up @@ -164,6 +171,10 @@ private static void areEqual(ITypeSerializationInfo[] left, ITypeSerializationIn
if (context == "Parameters.parameter.BackboneElement.value" || context == "Parameters.parameter.BackboneElement.part.BackboneElement.value")
return;

// This is an exception because from R4+ UsageContext.value doesn't have choice type of Reference anymore, but we still have it in Base to accomodate STU3 users.
if (context == "UsageContext.value")
return;

left.Length.Should().Be(right.Length, context + ": nr. of elements differs.");
foreach (var leftItem in left)
{
Expand Down

0 comments on commit a061001

Please sign in to comment.