public void CanInsertDishIntoDatabase() { using var _context = new RestaurantOrderContext(_builder.Options); var dish = new Dish() { DishName = "Spaghetti Bolognese", Price = 9.99M }; _context.Dishes.Add(dish); Assert.AreEqual(EntityState.Added, _context.Entry(dish).State); _context.SaveChanges(); Assert.AreEqual(EntityState.Unchanged, _context.Entry(dish).State); }
public void Save() { _context.SaveChanges(); }
protected virtual void Add <T>(T entity) where T : class { _context.Add(entity); _context.SaveChanges(); }