public void ReIndextags_TotalTags_Success() { TagsController controller = new TagsController(mockTagService.Object); this.SetupControllerTests(controller, "http://localhost/STCRMService/api/tags", HttpMethod.Get); var mockResponse = mockRepository.Create <ReIndexTagsResponse>(); mockTagService.Setup(c => c.ReIndexTags(It.IsAny <ReIndexTagsRequest>())).Returns(mockResponse.Object); var httpResponseMessage = controller.ReIndexTags(); var actionResponse = httpResponseMessage.Content.ReadAsAsync <ReIndexTagsResponse>().ContinueWith( t => { return(t.Result); }).Result; mockRepository.VerifyAll(); //Assert.IsFalse(actionResponse.IndexedTags, 1); Assert.AreEqual(actionResponse.Exception, null); Assert.AreEqual(httpResponseMessage.StatusCode, HttpStatusCode.OK); }
public void ReIndextags_TotalTags_RuntimeError_500InternalServerError() { TagsController controller = new TagsController(mockTagService.Object); this.SetupControllerTests(controller, "http://localhost/STCRMService/api/tags", HttpMethod.Get); var mockResponse = mockRepository.Create <ReIndexTagsResponse>(); mockTagService.Setup(c => c.ReIndexTags(It.IsAny <ReIndexTagsRequest>())).Returns(mockResponse.Object); mockResponse.Setup(r => r.Exception).Returns(new InvalidOperationException()); var httpResponseMessage = controller.ReIndexTags(); var postResponse = httpResponseMessage.Content.ReadAsAsync <ReIndexTagsResponse>().ContinueWith( t => { return(t.Result); }).Result; mockRepository.VerifyAll(); Assert.AreEqual(httpResponseMessage.StatusCode, HttpStatusCode.InternalServerError); Assert.AreNotEqual(postResponse.Exception, null); }