예제 #1
0
        public void MapTo_When_Not_Mapper_Return_Must_ThrowExceprion()
        {
            var entity = new TrackRawDataEntity {
                ProductId = (sbyte)ProductEnum.ERP, CreateTime = DateTime.Now
            };

            Assert.Throws <AutoMapperMappingException>(() => { MapperExtension.MapTo <TrackRawDataDto, TrackRawDataEntity>(entity); }, message: " Missing type map configuration or unsupported mapping.");
        }
예제 #2
0
        public void MapTo_When_Mapped_Return_Must_Not_Be_Bull()
        {
            var entity = new TrackRawDataDto {
                Product = ProductEnum.ERP, CreateTime = DateTime.Now
            };
            var result = MapperExtension.MapTo <TrackRawDataEntity, TrackRawDataDto>(entity);

            Assert.IsNotNull(result);
            Assert.AreEqual(result.ProductId, (sbyte)entity.Product);
            Assert.AreEqual(result.CreateTime, entity.CreateTime.Date);
        }
예제 #3
0
        public static void Test()
        {
            MapperExtension.CreateMapperByAssembly(new string[] { "ConsoleTest" });
            var entity = new TrackRawDataDto {
                Product = ProductEnum.ERP, CreateTime = DateTime.Now
            };
            var list = new List <TrackRawDataDto>();

            list.Add(entity);
            list.Add(entity);
            var result  = MapperExtension.MapTo <TrackRawDataEntity, TrackRawDataDto>(entity);
            var result1 = MapperExtension.MapTo <TrackRawDataEntity, TrackRawDataDto>(list);
        }