public void CanMapAnonymousType() { var from = new { Prop1 = "Prop1", Prop2 = "Prop2", Prop3 = "Prop3", Prop4 = 99f, Address = new { FirstName = "John", LastName = "Doe", Age = 24 } }; var to = new MapClass2(); MiniMapper.Map(from, to); Assert.AreEqual(from.Prop1, to.Prop1); Assert.AreEqual(from.Prop2, to.Prop2); Assert.AreEqual(from.Prop3, to.Prop3); Assert.AreEqual(from.Prop4, to.Prop4); var dict = to.Address; Assert.AreEqual(dict.Count, 3); Assert.AreEqual(dict["FirstName"], from.Address.FirstName); Assert.AreEqual(dict["LastName"], from.Address.LastName); Assert.AreEqual(dict["Age"], from.Address.Age); }
public void CanMap2() { var from = new MapClass2 { Prop1 = "Prop1", Prop2 = "Prop2", Prop3 = "Prop3" }; from.Address["FirstName"] = "John"; from.Address["LastName"] = "Doe"; from.Address["Age"] = 24; var to = MiniMapper.Map <MapClass2, MapClass1>(from); Assert.AreEqual(from.Prop1, to.Prop1); Assert.AreEqual(from.Prop2, to.Prop2); Assert.AreEqual(from.Prop3, to.Prop3); var dict = from.Address; Assert.AreEqual(dict.Count, 3); Assert.AreEqual(dict["FirstName"], to.Address.FirstName); Assert.AreEqual(dict["LastName"], to.Address.LastName); Assert.AreEqual(dict["Age"], to.Address.Age); }