public CatalogRepositoryTests() { var logger = new Mock <ILogger>(); var builder = new WebHostBuilder() .UseEnvironment("UnitTesting") .UseStartup <Startup>(); var server = new TestServer(builder); _context = server.Host.Services.GetService(typeof(CatalogContext)) as CatalogContext; _repository = new CatalogRepository(_context, logger.Object); _catalogBrands = TestCatalog.CreateBrands(); _catalogTypes = TestCatalog.CreateTypes(); _catalogResponse = TestCatalog.CreateItems(); _context.AddRange(_catalogBrands); _context.AddRange(_catalogTypes); _context.AddRange(_catalogResponse.ItemsOnPage); _context.SaveChanges(); }