Esempio n. 1
0
        public void ReIndexOpportunities_TotalOpprtunity_Success()
        {
            OpportunitiesController controller = new OpportunitiesController(mockContactService.Object, mockOpportunitiesService.Object);

            this.SetupControllerTests(controller, "http://localhost/STCRMService/api/tags", HttpMethod.Get);
            var mockResponse = mockRepository.Create <ReIndexDocumentResponse>();

            mockOpportunitiesService.Setup(c => c.ReIndexOpportunities(It.IsAny <ReIndexDocumentRequest>())).Returns(mockResponse.Object);

            var httpResponseMessage = controller.ReIndexOpportunities();
            var actionResponse      = httpResponseMessage.Content.ReadAsAsync <ReIndexDocumentResponse>().ContinueWith(
                t => { return(t.Result); }).Result;

            mockRepository.VerifyAll();
            Assert.AreEqual(actionResponse.Exception, null);
            Assert.AreEqual(httpResponseMessage.StatusCode, HttpStatusCode.OK);
        }
Esempio n. 2
0
        public void ReIndexOpportunities_TotalTags_RuntimeError_500InternalServerError()
        {
            OpportunitiesController controller = new OpportunitiesController(mockContactService.Object, mockOpportunitiesService.Object);

            this.SetupControllerTests(controller, "http://localhost/STCRMService/api/tags", HttpMethod.Get);
            var mockResponse = mockRepository.Create <ReIndexDocumentResponse>();

            mockOpportunitiesService.Setup(c => c.ReIndexOpportunities(It.IsAny <ReIndexDocumentRequest>())).Returns(mockResponse.Object);
            mockResponse.Setup(r => r.Exception).Returns(new InvalidOperationException());

            var httpResponseMessage = controller.ReIndexOpportunities();
            var postResponse        = httpResponseMessage.Content.ReadAsAsync <ReIndexDocumentResponse>().ContinueWith(
                t => { return(t.Result); }).Result;

            mockRepository.VerifyAll();

            Assert.AreEqual(httpResponseMessage.StatusCode, HttpStatusCode.InternalServerError);
            Assert.AreNotEqual(postResponse.Exception, null);
        }