Beispiel #1
0
        public void ShouldConvertUsingRegisterMapping()
        {
            // Arrange
            var model = new ModelA {
                Name = "Thomas", Age = 30
            };

            IConverterRegistry converterRegistry = new ConverterRegistry();

            converterRegistry.RegisterMapping <ModelA, ViewModelA>(src => src.Name, dest => dest.Name);
            converterRegistry.RegisterMapping <ModelA, ViewModelA>(src => src.Age, dest => dest.Age);

            // Act
            var viewModelA = converterRegistry.Convert <ModelA, ViewModelA>(model);

            // Assert
            viewModelA.Name.Should().Be("Thomas");
            viewModelA.Age.Should().Be(30);
        }