public void TestListBloggersAutoMapperMapperConfigDto() { //SETUP var config = new MapperConfiguration(cfg => { cfg.CreateMap <Mapper, Mapper>(); }); var options = SqliteInMemory.CreateOptions <CodeDataContext>(); using (var context = new CodeDataContext(options)) { context.Database.EnsureCreated(); context.AddRange(SetupPosts()); context.SaveChanges(); var logs = new List <string>(); SqliteInMemory.SetupLogging(context, logs); //ATTEMPT var dtos = context.Bloggers .ProjectTo <ListBloggersDto>(config) .ToList(); //VERIFY dtos.Count.ShouldEqual(2); dtos.Select(x => x.Name).ShouldEqual(new[] { AdaName, SherlockName }); dtos.Select(x => x.PostsCount).ShouldEqual(new[] { 2, 1 }); foreach (var log in logs) { _output.WriteLine(log); } } }
public UserServicesTest() { _codedataContext = TestHelpers.GetCodeDataContext(); AutoMapperConfig.Initialize(); var mapper = AutoMapperConfig.GetMapper(); _userServices = new UserServices(_codedataContext, mapper); }
private UserServicesFake GetInMemoryPersonRepository() { DbContextOptions <CodeDataContext> options; var builder = new DbContextOptionsBuilder <CodeDataContext>(); builder.UserServicesFake(); options = builder.Options; var personDataContext = new CodeDataContext(options); personDataContext.Database.EnsureDeleted(); personDataContext.Database.EnsureCreated(); return(new UserServicesFake(CodeDataContext)); }
public UserControllerTest() { _codeDataContext = TestHelpers.GetCodeDataContext(); AutoMapperConfig.Initialize(); var mapper = AutoMapperConfig.GetMapper(); var userServices = new UserServices(_codeDataContext, mapper); var storeServices = new StoreServices(_codeDataContext, mapper); var options = Options.Create(new LocalizationOptions()); // you should not need any params here if using a StringLocalizer<T> var factory = new ResourceManagerStringLocalizerFactory(options, NullLoggerFactory.Instance); var localizer = new ResourcesServices <CommonResources>(factory); var httpContext = new DefaultHttpContext(); var tempData = new TempDataDictionary(httpContext, Mock.Of <ITempDataProvider>()) { ["Success"] = localizer.GetLocalizedHtmlString("msg_AddSuccess") }; _userController = new UserController(userServices, storeServices, localizer) { TempData = tempData }; }
public UserServices(CodeDataContext context, IMapper mapper) { _context = context; _mapper = mapper; }
public ProductServices(CodeDataContext context, IMapper mapper) { _context = context; _mapper = mapper; }
public CategoryServices(CodeDataContext context, IMapper mapper) { _context = context; _mapper = mapper; }
public LoginServices(CodeDataContext context) { _context = context; }