public void TestResourceNameResolving() { var inspector = new ModelInspector(); inspector.ImportType(typeof(Road)); inspector.ImportType(typeof(Way)); inspector.ImportType(typeof(ProfiledWay)); inspector.ImportType(typeof(NewStreet)); //inspector.Process(); var road = inspector.FindClassMappingForResource("roAd"); Assert.IsNotNull(road); Assert.AreEqual(road.NativeType, typeof(Road)); var way = inspector.FindClassMappingForResource("Way"); Assert.IsNotNull(way); Assert.AreEqual(way.NativeType, typeof(Way)); var pway = inspector.FindClassMappingForResource("way", "http://nu.nl/profile#street"); Assert.IsNotNull(pway); Assert.AreEqual(pway.NativeType, typeof(ProfiledWay)); var pway2 = inspector.FindClassMappingForResource("way", "http://nux.nl/profile#street"); Assert.IsNotNull(pway2); Assert.AreEqual(pway2.NativeType, typeof(Way)); var street = inspector.FindClassMappingForResource("Street"); Assert.IsNotNull(street); Assert.AreEqual(street.NativeType, typeof(NewStreet)); var noway = inspector.FindClassMappingForResource("nonexistent"); Assert.IsNull(noway); }
public void TestAssemblyInspection() { var inspector = new ModelInspector(); // Inspect the HL7.Fhir.Model assembly inspector.Import(typeof(Resource).Assembly); // Check for presence of some basic ingredients Assert.IsNotNull(inspector.FindClassMappingForResource("patient")); Assert.IsNotNull(inspector.FindClassMappingForFhirDataType("HumanName")); Assert.IsNotNull(inspector.FindClassMappingForFhirDataType("code")); Assert.IsNotNull(inspector.FindClassMappingForFhirDataType("boolean")); // Verify presence of nested enumerations Assert.IsNotNull(inspector.FindEnumMappingByType(typeof(Address.AddressUse))); // Should have skipped abstract classes Assert.IsNull(inspector.FindClassMappingForResource("ComplexElement")); Assert.IsNull(inspector.FindClassMappingForResource("Element")); Assert.IsNull(inspector.FindClassMappingForResource("Resource")); // The open generic Code<> should not be there var codeOfT = inspector.FindClassMappingByType(typeof(Code<>)); Assert.IsNull(codeOfT); }