コード例 #1
0
        public void BookingController_CheckForValidPNR_Are_Equal()
        {
            //Arrange
            var mockRepository = new Mock <IBookingManager>();
            CreateBookingRequestDeatils moqdata = new CreateBookingRequestDeatils();

            mockRepository.Setup(x => x.MakeBooking(moqdata)).ReturnsAsync(new Tuple <HttpStatusCode, string>(HttpStatusCode.OK, "27373"));
            var controller = new BookingsController(mockRepository.Object);

            //Act
            var result        = controller.MakeBooking(moqdata);
            var contentResult = result.Result as OkNegotiatedContentResult <BookingResponse>;

            //Assert
            Assert.IsNotNull(contentResult);
            Assert.IsNotNull(contentResult.Content);
            Assert.AreEqual(contentResult.Content.PNR, "27373");
        }
コード例 #2
0
        public void BookingController_NotValidFlightDetail_BAD_REQUEST()
        {
            //Arrange
            var mockRepository = new Mock <IBookingManager>();
            CreateBookingRequestDeatils moqdata = new CreateBookingRequestDeatils();

            moqdata.FlightDetails = new FlightDetailRequest
            {
                DepartureCityCode = "DXB",
                ArrivalCityCode   = ""
            };

            mockRepository.Setup(x => x.MakeBooking(moqdata)).ReturnsAsync(new Tuple <HttpStatusCode, string>(HttpStatusCode.BadRequest, "bad request"));

            var controller = new BookingsController(mockRepository.Object);

            //Act
            var result        = controller.MakeBooking(moqdata);
            var contentResult = result.Result as BadRequestErrorMessageResult;

            //Assert
            Assert.IsInstanceOfType(contentResult, typeof(BadRequestErrorMessageResult));
            Assert.AreEqual(contentResult.Message, "bad request");
        }