private void ClearAfterTest(PracticalTestContext _context) { _context.Persons.RemoveRange(_context.Persons.Where(x => x.PersonID > 0)); _context.Employees.RemoveRange(_context.Employees.Where(x => x.EmployeeId > 0)); _context.TitleLookups.RemoveRange(_context.TitleLookups.Where(x => x.TitleId > 0)); _context.SaveChanges(); }
private void InitData(PracticalTestContext _context) { ClearAfterTest(_context); var employeeList = new List <Employee>(); for (int i = 0; i < AccountCount; i++) { employeeList.Add(new Employee { EmployeeNo = RandomString(26), Person = new Person { Surname = RandomString(26), Name = RandomString(26), } }); } _context.Employees.AddRange(employeeList); _context.SaveChanges(); }