Ejemplo n.º 1
0
        public async Task Automapping_should_work_with_enums_tostring()
        {
            //Arrange
            MappingHandler.AddMapping(MappingHandler.AutoConverter <ToObject, FromObject>(MappingPropertySource.Target, requireAllProperties: true));
            var fromObject = new ToObject()
            {
                Name      = "Testsson",
                TestValue = TestEnum.No,
                Age       = 22
            };

            //Act
            var toObject = await fromObject.ConvertAsync <FromObject>();

            //Assert
            toObject.EnumValue.Should().Be("No");
        }
Ejemplo n.º 2
0
        public async Task Mapping_Should_Work_With_Unwrapped_Elements()
        {
            //Arrange
            MappingHandler.AddMapping <WrappedValue, string>((source) => source.Value);
            MappingHandler.AddMapping(MappingHandler.AutoConverter <ToObject, FromObject>(MappingPropertySource.Target, requireAllProperties: true));

            var fromObject = new ToObject()
            {
                Name         = "Testsson",
                WrappedValue = new WrappedValue()
                {
                    Value = "sklep"
                },
                Age = 22
            };

            //Act
            var toObject = await fromObject.ConvertAsync <FromObject>();

            //Assert
            fromObject.WrappedValue.Value.Should().Be(toObject.WrappedValue);
        }