public StatisticsServiceTests() { _tolkDbContext = CreateTolkDbContext(); _clock = new StubSwedishClock(DateTimeOffset.Now.ToString()); var mockLanguages = MockEntities.MockLanguages; var mockRankings = MockEntities.MockRankings; var mockCustomers = MockEntities.MockCustomers; var mockCustomerUsers = MockEntities.MockCustomerUsers(mockCustomers); var mockOrders = MockEntities.MockOrders(mockLanguages, mockRankings, mockCustomerUsers); var mockRequisitions = MockEntities.MockRequisitions(mockOrders); var mockComplaints = MockEntities.MockComplaints(mockOrders); var regions = Region.Regions; //Initialize data if not already initialized if (!_tolkDbContext.CustomerOrganisations.Any()) { _tolkDbContext.AddRange(mockCustomers); _tolkDbContext.AddRange(mockCustomerUsers); _tolkDbContext.AddRange(mockLanguages); _tolkDbContext.AddRange(mockRankings); _tolkDbContext.AddRange(mockOrders); _tolkDbContext.AddRange(mockRequisitions); _tolkDbContext.AddRange(mockComplaints); _tolkDbContext.AddRange(regions); } _tolkDbContext.SaveChanges(); _statService = new StatisticsService(_tolkDbContext, _clock); }