public void DontMapTo_Test() { //FooForMapper canot mapto FooForMapperModel var foo = new FooForMapper() { floatValueForDontMapTo = 2.33f }; var foo2 = foo.MapTo <FooForMapperModel>(); foo2.floatValueForDontMapTo.ShouldBe(0, 0.1); var foo3 = foo.MapTo <FooForMapperModel2>(); foo3.floatValueForDontMapTo.ShouldBe(2.33f, 0.1); }
public void Map_Test() { var foo = new FooForMapper() { StrValue = "333" }; var fooModel = foo.MapTo <FooForMapperModel>(); fooModel.StrValue.ShouldBe("333"); }
public void IgnoreMemberMap_Test() { var obj1 = new FooForMapperModel() { StrValueForIgnoreMapAttribute = "123" }; var obj2 = obj1.MapTo <FooForMapper>(); obj2.StrValueForIgnoreMapAttribute.ShouldBeNull(); obj2 = new FooForMapper() { StrValueForIgnoreMapAttribute = "456" }; obj1 = obj2.MapTo <FooForMapperModel>(); obj1.StrValueForIgnoreMapAttribute.ShouldBe("456"); }
public void OnlyMapTo_Test() { //Only FooForMapper.DoubleValueForOnlyMapAttribute MapTo FooForMapperModel //Try FooForMapperModel To FooForMapper var foo = new FooForMapperModel() { DoubleValueForOnlyMapAttribute = 3.33 }; var foo2 = foo.MapTo <FooForMapper>(); foo2.DoubleValueForOnlyMapAttribute.ShouldBe(0, 0.1); //Try FooForMapper To FooForMapperModel foo2 = new FooForMapper() { DoubleValueForOnlyMapAttribute = 777.777 }; foo = foo2.MapTo <FooForMapperModel>(); foo.DoubleValueForOnlyMapAttribute.ShouldBe(777.777, 0.1); }
public void OnlyMapFrom_Test() { //Only FooForMapperModel.IntValuForOnlyMapAttribute MapTo FooForMapper //Try FooForMapperModel To FooForMapper var foo = new FooForMapperModel() { IntValueForOnlyMapAttribute = 666 }; var foo2 = foo.MapTo <FooForMapper>(); foo2.IntValueForOnlyMapAttribute.ShouldBe(666); //Try FooForMapper To FooForMapperModel foo2 = new FooForMapper() { IntValueForOnlyMapAttribute = 777 }; foo = foo2.MapTo <FooForMapperModel>(); foo.IntValueForOnlyMapAttribute.ShouldBe(0); }