public Status Update(Status item) { Repo.Update(item); Unit.SaveChanges(); return item; }
public IHttpActionResult Put(Status 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 IHttpActionResult Post(Status item) { Status Created = Logic.Create(item); return Ok(Created); }
public void StatusRepository() { Mock<IDbSetFactory> factory = new Mock<IDbSetFactory>(); Mock<DbSet<Status>> dbSet = new Mock<DbSet<Status>>(); factory.Setup(m => m.CreateDbSet<Status>()).Returns(dbSet.Object); StatusRepository repo = new StatusRepository(factory.Object); var Status = new Status(); var sequence = new MockSequence(); dbSet.InSequence(sequence).Setup(e => e.Add(Status)); dbSet.InSequence(sequence).Setup(e => e.Find(Status.Id)); dbSet.InSequence(sequence).Setup(e => e.Find(Status.Id)); dbSet.InSequence(sequence).Setup(e => e.Find(Status.Id)); repo.Create(Status); repo.Get(Status.Id); repo.Update(Status); repo.Delete(Status.Id); }
public void StatusLogic() { Mock<IUnitOfWork> uow = new Mock<IUnitOfWork>(); Mock<IStatusRepository> repo = new Mock<IStatusRepository>(); Mock<ITeamLogic> teamLogic = new Mock<ITeamLogic>(); StatusLogic logic = new StatusLogic(uow.Object, repo.Object, teamLogic.Object); var status = new Status(); var sequence = new MockSequence(); repo.InSequence(sequence).Setup(r => r.Create(status)); repo.InSequence(sequence).Setup(r => r.Update(status)); repo.InSequence(sequence).Setup(r => r.Get(status.Id)); repo.InSequence(sequence).Setup(r => r.Delete(status.Id)); logic.Create(status); logic.Update(status); logic.Get(status.Id); logic.Delete(status.Id); }