Exemplo n.º 1
0
        public void SourcePropertyMapsToSameDestinationPropertyIfNameIsNotSpecified()
        {
            // Arrange
            var source = _fixture.Create<SourceObject>();
            Mapper.CreateMap<SourceObject, DestinationObject>();
            var destination = new DestinationObject();

            // Act
            destination = Mapper.Map(source, destination);

            // Assert
            destination.SameProperty.Should().Be(source.SameProperty);
        }
Exemplo n.º 2
0
        public void SourcePropertyMapsToDestinationPropertyNamedOnlyForSpecifiedType()
        {
            // Arrange
            var source = _fixture.Create<SourceObject>();
            Mapper.CreateMap<SourceObject, DestinationObject>();
            var destination = new DestinationObject();

            // Act
            Mapper.Map(source, destination);

            // Assert
            destination.DestinationMappedProperty.Should().Be(source.SingleMappedProperty);
        }
Exemplo n.º 3
0
        public void MapThrowsNullReferenceExceptionIfTheSourceObjectIsNullAndTheDestinationObjectIsProvided()
        {
            // Arrange
            Mapper.ClearMappings();
            Mapper.CreateMap<SourceObject, DestinationObject>();
            SourceObject source = null;
            var destination = new DestinationObject();

            // Act
            Action action = () => Mapper.Map<SourceObject, DestinationObject>(source);

            // Assert
            action.ShouldNotThrow<NullReferenceException>();
        }