Beispiel #1
0
        public void GetBookingByFlightNo()
        {
            List <BookingModel> expectedResult = new List <BookingModel>
            {
                new BookingModel  {
                    BookingNo = 4, Date = new DateTime(2018, 3, 5), FlightNo = 2, PassengerName = "Karen Lom"
                },
                new BookingModel  {
                    BookingNo = 5, Date = new DateTime(2018, 3, 2), FlightNo = 2, PassengerName = "Mike Rom"
                },
                new BookingModel  {
                    BookingNo = 6, Date = new DateTime(2018, 3, 2), FlightNo = 2, PassengerName = "James B"
                },
                new BookingModel  {
                    BookingNo = 7, Date = new DateTime(2018, 3, 2), FlightNo = 2, PassengerName = "Linda A"
                }
            };

            // Arrange
            IAcmeRepository repo       = new AcmeRepository();
            var             mockLogger = new Mock <ILogger>();

            BookingsController controller = new BookingsController(repo, mockLogger.Object);

            // Act
            var result = controller.Get("", null, "", "", 2);

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(4, result.Count());
            Assert.IsTrue(result.SequenceEqual(expectedResult, new BookingModelComparer()), "Comparison of bookings failed");
        }
        public void GetAllBookings_ReturnsListWithCorrectNumberOfBokings_2()
        {
            var result       = bController.Get() as List <Booking>;
            var noOfBookings = result.Count;

            Assert.Equal(2, noOfBookings);
        }
Beispiel #3
0
        public void GetBookingByPassenger()
        {
            List <BookingModel> expectedResult = new List <BookingModel>
            {
                new BookingModel {
                    BookingNo = 2, Date = new DateTime(2018, 3, 2), FlightNo = 1, PassengerName = "Max Haler"
                },
                new BookingModel  {
                    BookingNo = 8, Date = new DateTime(2018, 3, 5), FlightNo = 3, PassengerName = "Max Haler"
                }
            };

            // Arrange
            IAcmeRepository repo       = new AcmeRepository();
            var             mockLogger = new Mock <ILogger>();

            BookingsController controller = new BookingsController(repo, mockLogger.Object);

            // Act
            var result = controller.Get("Max Haler");

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(2, result.Count());
            Assert.IsTrue(result.SequenceEqual(expectedResult, new BookingModelComparer()), "Comparison of bookings failed");
        }
        public void GetAllBookings_ReturnsOneBooking()
        {
            //ARRANGE
            //ACT
            var bookings = controller.Get();

            //ASSERT
            Assert.Single(bookings);
        }
Beispiel #5
0
        public void GetFromNumber()
        {
            var controller = new BookingsController(_bookingService);

            var getResponse = controller.Get("WO-291470");

            Assert.IsNotNull(getResponse);
            Assert.IsInstanceOfType(getResponse, typeof(FormattedContentResult <Booking>));
        }
Beispiel #6
0
        public void GetBookings()
        {
            var mockService = new Mock <IBookingService>();

            mockService.Setup(m => m.GetAll()).Returns(new List <Booking>());

            var controller = new BookingsController(mockService.Object);

            var result = controller.Get();

            Assert.Equal(result.ToList().Count, 0);
        }
Beispiel #7
0
        public void GetNotFoundFromNumber()
        {
            var controller = new BookingsController(_bookingService);

            var getResponse = controller.Get("WO-2914");

            Assert.IsNotNull(getResponse);
            Assert.IsInstanceOfType(getResponse, typeof(FormattedContentResult <string>));

            var result = getResponse as FormattedContentResult <string>;

            Assert.IsNotNull(result);
            Assert.AreEqual(HttpStatusCode.NotFound, result.StatusCode);
        }
Beispiel #8
0
        public void GetAll()
        {
            var controller = new BookingsController(_bookingService);

            var getAllResponse = controller.Get();

            Assert.IsNotNull(getAllResponse);
            Assert.IsInstanceOfType(getAllResponse, typeof(NegotiatedContentResult <string>));

            var result = getAllResponse as NegotiatedContentResult <string>;

            Assert.IsNotNull(result);
            Assert.AreEqual(HttpStatusCode.Forbidden, result.StatusCode);
        }
Beispiel #9
0
        public void GetFromNumberException()
        {
            var controller = new BookingsController(_bookingService);

            var getResponse = controller.Get("");
        }
Beispiel #10
0
        public void GetException()
        {
            var controller = new BookingsController(_bookingService);

            var getResponse = controller.Get(-1);
        }