예제 #1
0
        public void IgnoreValueMemberTest()
        {
            var currentDate = DateTime.Now;

            var objA = new ConfigA()
            {
                BirthDate = currentDate,
                Id        = 1,
                Name      = "Timuçin",
                Surname   = "KIVANÇ"
            };

            Mapper.Config <ConfigA, ConfigB>()
            .Ignore(dest => dest.Id);

            var objB = Mapper.Map <ConfigA, ConfigB>(objA);

            Assert.NotNull(objB);
            Assert.True(objB.Id == 0 && objB.FullName == null && objB.BirthDate == currentDate);
        }
예제 #2
0
        public void IgnoreReferenceMemberTest()
        {
            var currentDate = DateTime.Now;

            var objA = new ConfigA()
            {
                BirthDate = currentDate,
                Id        = 1,
                Name      = "Timuçin",
                Surname   = "KIVANÇ"
            };

            Mapper.Config <ConfigA, ConfigC>()
            .Ignore(dest => dest.Name)
            .Ignore(dest => dest.Surname);

            var objC = Mapper.Map <ConfigA, ConfigC>(objA);

            Assert.NotNull(objC);
            Assert.True(objC.Id == objA.Id && objC.BirthDate == currentDate);
            Assert.True(objC.Name == null && objC.Surname == null);
        }