public void TestPrimitiveDataTypeMapping() { var mapping = ClassMapping.Create(typeof(Base64Binary)); Assert.AreEqual("base64Binary", mapping.Name); Assert.IsTrue(mapping.HasPrimitiveValueMember); Assert.AreEqual(4, mapping.PropertyMappings.Count); var valueProp = mapping.PrimitiveValueProperty; Assert.IsNotNull(valueProp); Assert.AreEqual("value", valueProp.Name); Assert.IsFalse(valueProp.IsCollection); // don't see byte[] as a collection of byte in FHIR Assert.IsTrue(valueProp.RepresentsValueElement); mapping = ClassMapping.Create(typeof(Code <Address.AddressUse>)); Assert.AreEqual("codeOfT<Hl7.Fhir.Model.Address+AddressUse>", mapping.Name); Assert.IsTrue(mapping.HasPrimitiveValueMember); Assert.AreEqual(4, mapping.PropertyMappings.Count); valueProp = mapping.PrimitiveValueProperty; Assert.IsNotNull(valueProp); Assert.IsFalse(valueProp.IsCollection); Assert.IsTrue(valueProp.RepresentsValueElement); Assert.AreEqual(typeof(Address.AddressUse), valueProp.ElementType); mapping = ClassMapping.Create(typeof(FhirUri)); Assert.AreEqual("uri", mapping.Name); Assert.IsTrue(mapping.HasPrimitiveValueMember); Assert.AreEqual(4, mapping.PropertyMappings.Count); valueProp = mapping.PrimitiveValueProperty; Assert.IsNotNull(valueProp); Assert.IsFalse(valueProp.IsCollection); Assert.IsTrue(valueProp.RepresentsValueElement); Assert.AreEqual(typeof(Uri), valueProp.ElementType); }
public void TestResourceMappingCreation() { var mapping = ClassMapping.Create(typeof(Road)); Assert.IsTrue(mapping.IsResource); Assert.AreEqual("Road", mapping.Name); Assert.AreEqual(typeof(Road), mapping.NativeType); Assert.IsNull(mapping.Profile); mapping = ClassMapping.Create(typeof(Way)); Assert.IsTrue(mapping.IsResource); Assert.AreEqual("Way", mapping.Name); Assert.AreEqual(typeof(Way), mapping.NativeType); Assert.IsNull(mapping.Profile); mapping = ClassMapping.Create(typeof(ProfiledWay)); Assert.IsTrue(mapping.IsResource); Assert.AreEqual("Way", mapping.Name); Assert.AreEqual(typeof(ProfiledWay), mapping.NativeType); Assert.IsNotNull(mapping.Profile); mapping = ClassMapping.Create(typeof(NewStreet)); Assert.IsTrue(mapping.IsResource); Assert.AreEqual("Street", mapping.Name); Assert.AreEqual(typeof(NewStreet), mapping.NativeType); Assert.IsNull(mapping.Profile); }
public void TestDatatypeMappingCreation() { var mapping = ClassMapping.Create(typeof(AnimalName)); Assert.IsFalse(mapping.IsResource); Assert.AreEqual("AnimalName", mapping.Name); Assert.AreEqual(typeof(AnimalName), mapping.NativeType); Assert.IsNull(mapping.Profile); mapping = ClassMapping.Create(typeof(NewAnimalName)); Assert.IsFalse(mapping.IsResource); Assert.AreEqual("AnimalName", mapping.Name); Assert.AreEqual(typeof(NewAnimalName), mapping.NativeType); Assert.IsNull(mapping.Profile); }
public void TestMixedDataTypeDetection() { var mapping = ClassMapping.Create(typeof(ComplexNumber)); // cannot have a datatype with a profile.... }
public void TestMixedDataTypeDetection() { Assert.ThrowsException <ArgumentException>(() => ClassMapping.Create(typeof(ComplexNumber))); // cannot have a datatype with a profile.... }