Skip to content

Instantly share code, notes, and snippets.

@brendankowitz
Created November 20, 2020 15:07
Show Gist options
  • Save brendankowitz/fdfcd262822e0545d342e3ac03d4c03e to your computer and use it in GitHub Desktop.
Save brendankowitz/fdfcd262822e0545d342e3ac03d4c03e to your computer and use it in GitHub Desktop.
Extension differences
using System;
using System.Linq;
using Hl7.Fhir.Introspection;
using Hl7.Fhir.Model;
using Hl7.Fhir.Serialization;
using Xunit;
namespace TestProject1
{
public class UnitTest1
{
[Fact]
public void Test1()
{
var element = BaseFhirParser.Inspector.FindClassMappingByType("Extension");
var valueProp = element.PropertyMappings.First(x => x.Name == "value");
Assert.Equal(ChoiceType.DatatypeChoice, valueProp.Choice);
Assert.Equal(49, valueProp.FhirType.Length);
}
}
}
using System;
using System.Linq;
using System.Reflection;
using Hl7.Fhir.Introspection;
using Hl7.Fhir.Model;
using Xunit;
namespace TestProject2
{
public class UnitTest1
{
[Fact]
public void Test1()
{
var extension = GetModelInspector().FindClassMapping("Extension");
var valueProp = extension.PropertyMappings.First(x => x.Name == "value");
Assert.Equal(ChoiceType.DatatypeChoice, valueProp.Choice);
// Why is this now 1?
Assert.Equal(1, valueProp.FhirType.Length);
}
private static ModelInspector GetModelInspector()
{
string methodName = "GetStructureDefinitionSummaryProvider";
MethodInfo modelInspectorMethod = typeof(ModelInfo).GetMethod(methodName, BindingFlags.NonPublic | BindingFlags.Static);
if (modelInspectorMethod == null)
{
throw new MissingMethodException(nameof(ModelInfo), methodName);
}
return (ModelInspector)modelInspectorMethod.Invoke(null, null);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment