public Food Update(Food item) { Repo.Update(item); Unit.SaveChanges(); return item; }
public IHttpActionResult Put(Food item) { if (!ModelState.IsValid) { return BadRequest(ModelState); } try { return Ok(Logic.Update(item)); } catch (DbUpdateConcurrencyException) { if (!Logic.Exists(item.Id)) { return NotFound(); } else { throw; } } }
public void FoodRepository() { Mock<IDbSetFactory> factory = new Mock<IDbSetFactory>(); Mock<DbSet<Food>> dbSet = new Mock<DbSet<Food>>(); factory.Setup(m => m.CreateDbSet<Food>()).Returns(dbSet.Object); FoodRepository repo = new FoodRepository(factory.Object); var Food = new Food(); var sequence = new MockSequence(); dbSet.InSequence(sequence).Setup(e => e.Add(Food)); dbSet.InSequence(sequence).Setup(e => e.Find(Food.Id)); dbSet.InSequence(sequence).Setup(e => e.Find(Food.Id)); dbSet.InSequence(sequence).Setup(e => e.Find(Food.Id)); repo.Create(Food); repo.Get(Food.Id); repo.Update(Food); repo.Delete(Food.Id); }
public void FoodLogic() { Mock<IUnitOfWork> uow = new Mock<IUnitOfWork>(); Mock<IFoodRepository> repo = new Mock<IFoodRepository>(); Mock<ITeamLogic> teamLogic = new Mock<ITeamLogic>(); FoodLogic logic = new FoodLogic(uow.Object, repo.Object, teamLogic.Object); var food = new Food(); var sequence = new MockSequence(); repo.InSequence(sequence).Setup(r => r.Create(food)); repo.InSequence(sequence).Setup(r => r.Update(food)); repo.InSequence(sequence).Setup(r => r.Get(food.Id)); repo.InSequence(sequence).Setup(r => r.Delete(food.Id)); logic.Create(food); logic.Update(food); logic.Get(food.Id); logic.Delete(food.Id); }
public IHttpActionResult Post(Food item) { Food Created = Logic.Create(item); return Ok(Created); }
public Food Create(Food item) { Repo.Create(item); Unit.SaveChanges(); return item; }