public void Test__Basic() { // Arrange var expected = _fixture.Create <ComplexModelSource>(); var childObj = new ExpandoObject(); var childObjDictionary = (IDictionary <string, object>)childObj; childObjDictionary["Name"] = expected.ParentInfo.Name; childObjDictionary["Age"] = expected.ParentInfo.Age; childObjDictionary["DateOfBith"] = expected.ParentInfo.DateOfBith; var rootObj = new ExpandoObject(); var rootObjDictionary = (IDictionary <string, object>)rootObj; rootObjDictionary["Name"] = expected.Name; rootObjDictionary["Age"] = expected.Age; rootObjDictionary["DateOfBith"] = expected.DateOfBith; rootObjDictionary["ParentInfo"] = expected.ParentInfo; // Act var result = DynamicMap.Map(typeof(ComplexModelDestination), rootObj); // Assert Assert(expected, result, new ComplexModelComparer()); }
public void Test__Basic() { // Arrange var obj = _fixture.Create <EnumerableModelSource>(); // Act var result = DynamicMap.Map(typeof(EnumerableModelDestination), obj); // Assert Assert(obj, result, new EnumerableModelComparer()); }
public void Test__decimal_to_int() { // Arrange var value = _fixture.Create <decimal>(); // Act var result = DynamicMap.Map <int>(value); // Assert Assert.Equal((int)value, result); }
public void Test__int_to_decimal() { // Arrange var value = _fixture.Create <int>(); // Act var result = DynamicMap.Map <decimal>(value); // Assert Assert.Equal(new decimal(value), result); }
public void Test__string_to_int() { // Arrange var value = _fixture.Create <int>(); // Act var result = DynamicMap.Map <int>(value.ToString()); // Assert Assert.Equal(value, result); }
public void Test__Basic() { // Arrange var obj = _fixture.Create <List <string> >(); // Act var result = DynamicMap.Map(typeof(List <string>), obj); // Assett Assert.Equal(obj, result); }
public void Test__Basic() { // Arrange var obj = _fixture.Create <ComplexModelSource>(); var json = JsonConvert.DeserializeObject(JsonConvert.SerializeObject(obj)); // Act var result = DynamicMap.Map(typeof(ComplexModelSource), json); // Assert Assert.Equal(obj, result); }
public void Test__Basic() { // Arrange var obj = _fixture.Create <CustomClass>(); // Act DynamicMap.GetDynamicMapBuilder().RegisterCustomMapper(new CustomClassSpecialMapper()); var result = (CustomClass)DynamicMap.Map(typeof(CustomClass), new { CustomProp = obj.CustomProp }); // Assert Assert.True(obj.CustomProp == result.CustomProp && Flag.FlagValue); }