public void Map_PrimitiveProperty_Success() { var builder = new ClassMapperBuilder(new MappingBuilderConfigStub()); Mapper mapper = builder.Build(new TypePair(typeof(PropertySource), typeof(PropertyTarget))); var source = new PropertySource { Bool = true, Byte = 0, Char = 'a', Decimal = 4.0m, Float = 2.0f, Int = 9, Long = 2, Sbyte = 8, Short = 1, String = "test", Ulong = 3, Ushort = 7, DateTime = new DateTime(1990, 1, 1), DateTimeOffset = new DateTimeOffset(new DateTime(1998, 3, 5)), DateTimeNullable = null, DateTimeNullable1 = new DateTime(2020, 2, 4) }; var actual = (PropertyTarget)mapper.Map(source); Assert.Equal(source.Bool, actual.Bool); Assert.Equal(source.Byte, actual.Byte); Assert.Equal(source.Char, actual.Char); Assert.Equal(source.Decimal, actual.Decimal); Assert.Equal(source.Float, actual.Float); Assert.Equal(source.Int, actual.Int); Assert.Equal(source.Long, actual.Long); Assert.Equal(source.Sbyte, actual.Sbyte); Assert.Equal(source.Short, actual.Short); Assert.Equal(source.String, actual.String); Assert.Equal(source.Ulong, actual.Ulong); Assert.Equal(source.Ushort, actual.Ushort); Assert.Equal(source.DateTime, actual.DateTime); Assert.Equal(source.DateTimeOffset, actual.DateTimeOffset); Assert.Equal(source.DateTimeNullable, actual.DateTimeNullable); Assert.Equal(source.DateTimeNullable1, actual.DateTimeNullable1); }
public void Map_PrimitiveField_Success() { var builder = new ClassMapperBuilder(new MappingBuilderConfigStub()); Mapper mapper = builder.Build(new TypePair(typeof(FiledSource), typeof(FiledTarget))); var source = new FiledSource { Bool = true, Byte = 0, Char = 'a', Decimal = 4.0m, Float = 2.0f, Int = 9, Long = 2, Sbyte = 8, Short = 1, String = "test", Ulong = 3, Ushort = 7 }; var actual = (FiledTarget)mapper.Map(source); Assert.Equal(source.Bool, actual.Bool); Assert.Equal(source.Byte, actual.Byte); Assert.Equal(source.Char, actual.Char); Assert.Equal(source.Decimal, actual.Decimal); Assert.Equal(source.Float, actual.Float); Assert.Equal(source.Int, actual.Int); Assert.Equal(source.Long, actual.Long); Assert.Equal(source.Sbyte, actual.Sbyte); Assert.Equal(source.Short, actual.Short); Assert.Equal(source.String, actual.String); Assert.Equal(source.Ulong, actual.Ulong); Assert.Equal(source.Ushort, actual.Ushort); }