public void SlotStorageOperations() { // Arrange TimeModel timeService = TimeModel.getService(); DateTime start = DateTime.Today; DateTime end = DateTime.Now; string desc = "A daily dummy job"; string project = "Test"; Slot createdSlot = new Slot(start, end, desc, project); // Act timeService.InsertSlot(createdSlot); long id = timeService.GetSlotIdByData(start, end, desc, project); Slot foundSlot = timeService.GetSlotByID(id); // Assert Assert.AreEqual(createdSlot, foundSlot); // Act createdSlot.Description = "An updated activity description"; timeService.UpdateSlot(createdSlot); foundSlot = timeService.GetSlotByID(id); // Assert Assert.AreEqual(foundSlot.Description, createdSlot.Description); // Act timeService.DeleteSlot(id); foundSlot = timeService.GetSlotByID(id); long noId = timeService.GetSlotIdByData(createdSlot.Start, createdSlot.End, createdSlot.Description, createdSlot.Project); // Assert Assert.IsNull(foundSlot); Assert.AreEqual(noId, TimeModel.NON_VALUE); }
public HttpResponseMessage Delete(long id) { bool result = false; TimeModel timeService = TimeModel.getService(); if (timeService.GetSlotByID(id) != null) { result = timeService.DeleteSlot(id); } else { throw new HttpResponseException(HttpStatusCode.NotFound); } return(new HttpResponseMessage(result ? HttpStatusCode.OK : HttpStatusCode.BadRequest)); }