Exemplo n.º 1
0
        public void FlattenFatherSonGrandsonDtoWithDestinationOk()
        {
            //SETUP
            Mapper.Register <Father, FlattenFatherSonGrandsonDto>()
            .Flatten();
            Mapper.Compile(CompilationTypes.Destination);

            //ATTEMPT
            var dto = new FlattenFatherSonGrandsonDto
            {
                MyInt    = 29387465,
                MyString = "whjqegfqwjehfg"
            };
            var father = Father.CreateOne();

            Mapper.Map(father, dto);

            //VERIFY
            Assert.AreEqual("Father", dto.MyString);    //This is mapped by the normal ExpressMapper
            Assert.AreEqual(1, dto.MyInt);              //This is mapped by the normal ExpressMapper
            Assert.AreEqual("Son", dto.SonMyString);
            Assert.AreEqual(2, dto.SonMyInt);
            Assert.AreEqual("Grandson", dto.SonGrandsonMyString);
            Assert.AreEqual(3, dto.SonGrandsonMyInt);
        }
Exemplo n.º 2
0
        public void FatherLowerCaseFlattenFatherSonGrandsonDtoOk()
        {
            //SETUP
            Mapper.Register <FatherLowerCase, FlattenFatherSonGrandsonDto>()
            .Flatten();
            Mapper.Compile(CompilationTypes.Source);

            //ATTEMPT
            var dto = new FlattenFatherSonGrandsonDto();

            Mapper.Map(FatherLowerCase.CreateOne(), dto);

            //VERIFY
            Assert.AreEqual("Father", dto.MyString);    //This is mapped by the normal ExpressMapper
            Assert.AreEqual(1, dto.MyInt);              //This is mapped by the normal ExpressMapper
            Assert.AreEqual("Son", dto.SonMyString);
            Assert.AreEqual(2, dto.SonMyInt);
            Assert.AreEqual("Grandson", dto.SonGrandsonMyString);
            Assert.AreEqual(3, dto.SonGrandsonMyInt);
        }