예제 #1
0
        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);
        }
예제 #2
0
        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);
        }