public void PlainNetMapperCanHandleSimpleFlatTypes() { OpenTypeKind mapsTo; Assert.IsTrue(mapper.CanHandle(typeof(SimpleFlatType), out mapsTo, CanHandle)); Assert.AreEqual(OpenTypeKind.CompositeType, mapsTo); OpenType mappedType = mapper.MapType(typeof(SimpleFlatType), MapType); Assert.AreEqual(OpenTypeKind.CompositeType, mappedType.Kind); CompositeType compositeType = (CompositeType)mappedType; Assert.AreEqual("SimpleFlatType", compositeType.TypeName); Assert.AreEqual("SimpleFlatType", compositeType.Description); Assert.IsTrue(compositeType.ContainsKey("IntValue")); Assert.IsTrue(compositeType.ContainsKey("StringValue")); Assert.AreEqual(2, compositeType.KeySet.Count); Assert.AreEqual(SimpleType.Integer, compositeType.GetOpenType("IntValue")); Assert.AreEqual(SimpleType.String, compositeType.GetOpenType("StringValue")); SimpleFlatType value = new SimpleFlatType(); value.IntValue = 5; value.StringValue = "A text"; object mappedValue = mapper.MapValue(typeof(SimpleFlatType), mappedType, value, MapValue); Assert.IsTrue(mappedValue is ICompositeData); ICompositeData compositeData = (ICompositeData)mappedValue; Assert.IsTrue(compositeType.IsValue(compositeData)); Assert.IsTrue(compositeData.ContainsKey("IntValue")); Assert.IsTrue(compositeData.ContainsKey("StringValue")); Assert.AreEqual(value.IntValue, compositeData["IntValue"]); Assert.AreEqual(value.StringValue, compositeData["StringValue"]); Assert.AreEqual(2, compositeData.Values.Count()); }
public void CollectionMapperCanHandleMappingIEnumerableToArray() { OpenTypeKind mapsTo; Assert.IsTrue(mapper.CanHandle(typeof(IEnumerable <int>), out mapsTo, CanHandle)); Assert.AreEqual(OpenTypeKind.ArrayType, mapsTo); }