public IHttpActionResult Post(Path item) { Path Created = null; try { Created = Logic.Create(item); } catch (Exception e) { } // The binary serializer is gross, so we skip it. return Ok(new { Data = Created.Data.Select(a => (int)a).ToArray(), ActivityId = Created.ActivityId, Id = Created.Id }); }
// PUT api/Activity/5 public IHttpActionResult Put(Path 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 PathRepository() { Mock<IDbSetFactory> factory = new Mock<IDbSetFactory>(); Mock<DbSet<Path>> dbSet = new Mock<DbSet<Path>>(); factory.Setup(m => m.CreateDbSet<Path>()).Returns(dbSet.Object); PathRepository repo = new PathRepository(factory.Object); var Path = new Path(); var sequence = new MockSequence(); dbSet.InSequence(sequence).Setup(e => e.Add(Path)); dbSet.InSequence(sequence).Setup(e => e.Find(Path.Id)); dbSet.InSequence(sequence).Setup(e => e.Find(Path.Id)); dbSet.InSequence(sequence).Setup(e => e.Find(Path.Id)); repo.Create(Path); repo.Get(Path.Id); repo.Update(Path); repo.Delete(Path.Id); }
public void PathLogic() { Mock<IUnitOfWork> uow = new Mock<IUnitOfWork>(); Mock<IPathRepository> repo = new Mock<IPathRepository>(); PathLogic logic = new PathLogic(uow.Object, repo.Object); var path = new Path(); var sequence = new MockSequence(); repo.InSequence(sequence).Setup(r => r.Create(path)); repo.InSequence(sequence).Setup(r => r.Update(path)); repo.InSequence(sequence).Setup(r => r.Get(path.Id)); repo.InSequence(sequence).Setup(r => r.Delete(path.Id)); logic.Create(path); logic.Update(path); logic.Get(path.Id); logic.Delete(path.Id); }