Beispiel #1
0
        // Execute a mapping from the source object to a new destination object.
        public virtual void Map_SourceTypeInferred_ReturnsDestinationType()
        {
            // Arrange
            var person = new Person {
                FirstName = "Johnny", LastName = "Smith", DoB = new DateTime(1984, 6, 5)
            };

            // Act
            var response = _objectMapper.Map <PersonEntity>(person);

            // Assert
            Assert.Equal(person.FirstName, response.FirstName);
            Assert.Equal(person.LastName, response.LastName);
            Assert.Equal(person.DoB, response.DoB);
        }
Beispiel #2
0
        public virtual void Map_SourceTypeKnown_ReturnsDestinationType()
        // Execute a mapping from the source object to a new destination object.
        {
            // Arrange
            var person = new Person {
                FirstName = "Johnny", LastName = "Smith", DoB = new DateTime(1984, 6, 5)
            };

            // Act
            var response = _objectMapper.Map <Person, PersonEntity>(person);

            // Assert
            Assert.Equal(person.FirstName, response.FirstName);
            Assert.Equal(person.LastName, response.LastName);
            Assert.Equal(person.DoB, response.DoB);
        }
Beispiel #3
0
        // Execute a mapping from the source object to a new destination object with explicit System.Type objects
        public virtual void Map_SourceToNewDestinationWithExplicitTypes_ReturnsDestinationType()
        {
            // Arrange
            var person = new Person {
                FirstName = "Johnny", LastName = "Smith", DoB = new DateTime(1984, 6, 5)
            };

            // Act
            var response = _objectMapper.Map(person, typeof(Person), typeof(PersonEntity));

            // Assert
            Assert.True(response is PersonEntity);
            var actualResponse = response as PersonEntity;

            Assert.Equal(person.FirstName, actualResponse.FirstName);
            Assert.Equal(person.LastName, actualResponse.LastName);
            Assert.Equal(person.DoB, actualResponse.DoB);
        }
Beispiel #4
0
        // Execute a mapping from the source object to the existing destination object.
        public virtual void Map_SourceTypeKnownMapIntoDestination_ReturnsDestinationType()
        {
            // Arrange
            var person = new Person {
                FirstName = "Johnny", LastName = "Smith", DoB = new DateTime(1984, 6, 5)
            };
            var expectedResponse = new PersonEntity();

            // Act
            var response = _objectMapper.Map(person, expectedResponse);

            // Assert
            Assert.Equal(person.FirstName, response.FirstName);
            Assert.Equal(person.LastName, response.LastName);
            Assert.Equal(person.DoB, response.DoB);
            Assert.Equal(person.FirstName, expectedResponse.FirstName);
            Assert.Equal(person.LastName, expectedResponse.LastName);
            Assert.Equal(person.DoB, expectedResponse.DoB);
        }