public void DeleteTour_DeactivateTourforContacts_Succeed() { ToursController controller = new ToursController(mockTourService.Object); this.SetupControllerTests(controller, "http://localhost/STCRMService/api/note/1", HttpMethod.Get); var mockResponse = mockRepository.Create <DeleteTourResponse>(); mockTourService.Setup(c => c.DeleteTour(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <int>())). Returns(mockResponse.Object); var httpResponseMessage = controller.DeleteTour(SAMPLE_TOUR_ID); var noteResponse = httpResponseMessage.Content.ReadAsAsync <DeleteTourResponse>().ContinueWith( t => { return(t.Result); }).Result; mockRepository.VerifyAll(); //Assert.AreEqual(noteResponse., null); Assert.AreEqual(httpResponseMessage.StatusCode, HttpStatusCode.OK); }
public void DeleteTour_DeactivateTourforContacts_RuntimeError_500InternalServerError() { ToursController controller = new ToursController(mockTourService.Object); this.SetupControllerTests(controller, "http://localhost/STCRMService/api/note", HttpMethod.Get); var mockResponse = mockRepository.Create <DeleteTourResponse>(); mockTourService.Setup(c => c.DeleteTour(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <int>())). Returns(mockResponse.Object); mockResponse.Setup(r => r.Exception).Returns(new InvalidOperationException()); var httpResponseMessage = controller.DeleteTour(SAMPLE_TOUR_ID); var postResponse = httpResponseMessage.Content.ReadAsAsync <DeleteTourResponse>().ContinueWith( t => { return(t.Result); }).Result; mockRepository.VerifyAll(); Assert.AreEqual(httpResponseMessage.StatusCode, HttpStatusCode.InternalServerError); Assert.AreNotEqual(postResponse.Exception, null); }