示例#1
0
 public HttpResponseMessage DeleteMilestone(Guid id)
 {
     try
     {
         _milestoneService.DeleteMilestone(id);
         return(Request.CreateResponse(HttpStatusCode.OK, "Successfully deleted a milestone!"));
     }
     catch (Exception ex)
     {
         return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message));
     }
 }
示例#2
0
 /// <summary>
 /// Delete milestone(s)
 /// </summary>
 /// <param name="Ids">Ids of milestones to be deleted</param>
 public ActionResult MilestoneDelete(List <int> Ids)
 {
     try
     {
         //Get user id
         int?userId = Session.GetUserId();
         MilestoneService milestoneService = new MilestoneService();
         milestoneService.DeleteMilestone(Ids, userId);
         return(new HttpStatusCodeResult(200));
     }
     catch (Exception e)
     {
         return(new HttpStatusCodeAndErrorResult(500, e.Message));
     }
 }
示例#3
0
        public void ShouldNotDeleteMilestoneFromSystemIfItHasBeenCompleted()
        {
            int expectedMilestoneId = 10;
            Milestone expectedMilestone = new Milestone(expectedMilestoneId, 100d, "Testing", DateTime.Now);

            //Setup the mocks
            mockRepository.Setup(r => r.Get(It.Is<int>(val => val == expectedMilestoneId))).Returns(expectedMilestone);
            IMilestoneService service = new MilestoneService(mockRepository.Object);

            //Act
            Action failAction = () => service.DeleteMilestone(expectedMilestoneId);

            //Assert
            failAction.Should().Throw<Exception>();
        }
示例#4
0
        public void ShouldDeleteMilestoneFromSystemByKnownId()
        {
            int expectedMilestoneId = 10;
            Milestone expectedMilestone = new Milestone(expectedMilestoneId, 100d, "Testing", null);

            //Setup the mocks
            mockRepository.Setup(r => r.Get(It.Is<int>(val => val == expectedMilestoneId))).Returns(expectedMilestone);
            mockRepository.Setup(r => r.Delete(It.Is<int>(val => val == expectedMilestoneId))).Returns(expectedMilestone);
            IMilestoneService service = new MilestoneService(mockRepository.Object);

            //Act
            Milestone removedMilestone = service.DeleteMilestone(expectedMilestoneId);

            //Assert
            removedMilestone.Should().NotBeNull();
            removedMilestone.Id.Should().Be(expectedMilestoneId);
            removedMilestone.Should().BeEquivalentTo(expectedMilestone);
        }