public void MapPathToCollectionThroughDeepStructure() { // Arrange var mapper = CreateMapper<DeepStructure>(new[] { "ComplexObject.Collection.IntElement", "ComplexObject.Collection.StringElement" }); var objectToMap = new DeepStructure { ComplexObject = new ListCollectionOfElementsWithIntAndString { Collection = new List<ElementWithIntAndString> { new ElementWithIntAndString { IntElement = 1, StringElement = "1" }, new ElementWithIntAndString { IntElement = 2, StringElement = "2" }, new ElementWithIntAndString { IntElement = 3, StringElement = "3" } } } }; // Act var mapping = mapper.Map(new object[] { objectToMap }); // Assert Assert.AreEqual(3, GetMappedPathFromCollection(mapping, 2, "ComplexObject.Collection.IntElement")); Assert.AreEqual("2", GetMappedPathFromCollection(mapping, 1, "ComplexObject.Collection.StringElement")); }
public void ShouldProperlyMapDeepStructureWithCollectionOfComplexObjects() { // Arrange var mapper = CreateMapper<DeepStructure>(new[] { "ComplexObjectHolder.Collection.Element", "ComplexObjectHolder.Collection", "ComplexObjectHolder.String", "ComplexObjectHolder.Int" }, new IComplexObjectDescriptor[] { new ComplexObjectMapper(), new BasicElementMapper() }); var objectToMap = new DeepStructure { ComplexObjectHolder = new ComplexObjectHolder { Collection = new List<BasicElement<ComplexObject>> { new BasicElement<ComplexObject> { Element = new ComplexObject() }, new BasicElement<ComplexObject> { Element = new ComplexObject() } }, String = "String", Int = 567 } }; // Act var mapping = mapper.Map(new object[] { objectToMap }); // Assert Assert.AreEqual(BasicElementWithComplexObjectCustomDescription, GetMappedPathFromCollection(mapping, 1, "ComplexObjectHolder.Collection")); }