Exemple #1
0
        public void MapNull_ToNewObject_Mapped()
        {
            StubMapSource source = null;
            var           mapper = new StubMapper();
            var           target = mapper.Map(source, true);

            Assert.NotNull(target);
        }
Exemple #2
0
        public void MapNull_ToNull_Mapped()
        {
            StubMapSource source = null;
            var           mapper = new StubMapper();
            var           target = mapper.Map(source);

            Assert.Null(target);
        }
Exemple #3
0
        public void CanMap_Test()
        {
            // arrange
            var source = new StubMapSource {
                FirstName = "John", LastName = "Doe"
            };
            var mapper = new Mapper <StubMapSource, StubMapTarget>((s, d) => d.FullName = $"{s.FirstName} {s.LastName}");

            // act
            var target = mapper.Map(source);

            // assert
            target.ShouldNotBeNull();
            target.FullName.ShouldBe("John Doe");
        }
Exemple #4
0
        public void CanMapNull_Test()
        {
            // arrange
            StubMapSource source = null;
            var           mapper = new Mapper <StubMapSource, StubMapTarget>((s, d) => d.FullName = $"{s.FirstName} {s.LastName}");

            // act
            var target1 = mapper.Map(source);
            var target2 = mapper.Map(source, true);

            // assert
            target1.ShouldBeNull();
            target2.ShouldNotBeNull();
            target2.FullName.ShouldBe(" ");
        }