public bool SaveChanges() { try { return(_db.SaveChanges() > 1); } catch (Exception ex) { return(false); } }
void AddEmployee() { var provider = services.BuildServiceProvider(); var cs = "Server=.;Database=EMPSYSDB;Integrated Security=True;"; var optionsBuilder = new DbContextOptionsBuilder <AppContext>(); optionsBuilder.UseSqlServer(cs); var _ctx = new AppContext(optionsBuilder.Options); // Arrange Employee employee = GenerateOneEmployee(); _ctx.Employees.Add(employee); // Act _ctx.SaveChanges(); var DbEmployees = _ctx.Employees.ToList(); // Assert Assert.Contains(employee, DbEmployees); }