public void ClearSeedData() { _context.Database.ExecuteSqlRaw("DELETE FROM SchoolResult"); _context.Database.ExecuteSqlRaw("DELETE FROM SchoolContextual"); _context.Database.ExecuteSqlRaw("DELETE FROM SchoolDetails"); _context.Database.ExecuteSqlRaw("DELETE FROM School"); _context.SaveChanges(); }
public void Setup() { //Create an InMemory Sqlite Database for testing var connection = new InMemorySqliteConnection(); _context = connection._context; //Create the repository class that will be tested _repositorySchool = new SchoolPerformanceRepository <School>(_context); _repositorySchoolResult = new SchoolPerformanceRepository <SchoolResult>(_context); //Mock data SetData(); //Remove existing seeded data ClearSeedData(); //Add and save the mock data to the context _schools.ForEach(x => _context.School.Add(x)); _schoolResults.ForEach(x => _context.SchoolResult.Add(x)); _context.SaveChanges(); }