Exemplo n.º 1
0
        public void GetTour_ForAnExistingContact_TourObjectFound()
        {
            var mockTour = TourMockData.CreateMockTourWithId(mockRepository, ACTIVE_CONTACT_ID);

            mockTourRepository.Setup(tr => tr.GetTourByID(It.IsAny <int>())).Returns(mockTour.Object);
            GetTourResponse response = new GetTourResponse();

            response = tourService.GetTour(ACTIVE_CONTACT_ID);

            mockRepository.VerifyAll();
            Assert.AreEqual(mockTour.Object.Id, response.TourViewModel.TourID);
        }
Exemplo n.º 2
0
        public void GetTour_GetTourforContact_ReturnSuccess()
        {
            ToursController controller = new ToursController(mockTourService.Object);

            this.SetupControllerTests(controller, "http://localhost/STCRMService/api/tour/1", HttpMethod.Get);

            var mockResponse = mockRepository.Create <GetTourResponse>();

            GetTourResponse response = mockRepository.Create <GetTourResponse>().Object;

            response.TourViewModel = MockData.CreateMockList <TourViewModel>(mockRepository).Select(c => c.Object).FirstOrDefault();
            mockTourService.Setup(c => c.GetTour(It.IsAny <int>())).Returns(response);
            var httpResponseMessage = controller.GetTour(SAMPLE_TOUR_ID);
            var contactResponse     = httpResponseMessage.Content.ReadAsAsync <GetTourResponse>().ContinueWith(
                t => { return(t.Result); }).Result;

            mockRepository.VerifyAll();
            Assert.AreEqual(httpResponseMessage.StatusCode, HttpStatusCode.OK);
            Assert.AreEqual(contactResponse.Exception, null);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Gets a Tour by tourId.
        /// </summary>
        /// <param name="tourId">Id of a tour</param>
        /// <returns>Tour Details</returns>
        public HttpResponseMessage GetTour(int tourId)
        {
            GetTourResponse response = tourService.GetTour(tourId);

            return(Request.BuildResponse(response));
        }