Пример #1
0
        public void TestMethod1()
        {
            AutoMapper.Mapper.CreateMap<AEntity, ADTO>();
            var s = new AEntity();
            s.S = "1;";

            var bb = s.ProjectedAs<ADTO>();

            Assert.AreEqual(bb.S, s.S);
        }
Пример #2
0
        public void TestMethod2()
        {
            AutoMapper.Mapper.CreateMap<AEntity, ADTO>()
                      .ForMember(dto => dto.S1, mc => mc.MapFrom(e => e.S))
                      .ReverseMap();
            ;
            var entity = new AEntity();
            entity.S = "1;";

            var bb = entity.ProjectedAs<ADTO>();

            Assert.AreEqual(bb.S, entity.S);
            Assert.AreEqual(entity.S, bb.S1);
        }
Пример #3
0
        public void TestMethod2_list()
        {
            AutoMapper.Mapper.CreateMap<AEntity, ADTO>()
                      .ForMember(dto => dto.S1, mc => mc.MapFrom(e => e.S))
                //.ReverseMap()
                      ;
            ;
            AEntity[] entity = new AEntity[]
                             {
                                 new AEntity{ S ="1"}
                             };

            IEnumerable<AEntity> fasdfasdf = entity.AsEnumerable();

            //var list = fasdfasdf.ProjectedAsCollection<ADTO>();


            var list = fasdfasdf.ProjectedAsCollection<ADTO>();

            Assert.IsNotNull(list);
            Assert.IsTrue(list.Count() > 0);
            Assert.AreEqual("1", list.ElementAt(0).S);



            //fasdfasdf.
        }