public void Book_Ticket_Failure_Test()
        {
            mock.Setup(x => x.BookTicket(It.IsAny <Ticket>())).Returns(false);
            var controller = new TicketController(mock.Object);
            var res        = controller.Book_Ticket(new Ticket()
            {
                TicketId = 7, Age = 35, PassengerName = "Hari", StartingLocation = "Rajamundry", Destination = "Hyderabad", FlightId = 4, DateOfJourney = new System.DateTime(2021, 3, 4)
            }) as NoContentResult;

            Assert.AreEqual(204, res.StatusCode);
        }
Exemplo n.º 2
0
        public void Book_Ticket_Success_Test()
        {
            Ticket ticket = new Ticket()
            {
                TicketId = 1, Age = 22, PassengerName = "Ram", FlightId = 1, StartingLocation = "Pune", Destination = "Agra", DateOfJourney = new System.DateTime(2020, 11, 24)
            };

            controller = new TicketController(ticketrepo);
            var res1 = controller.Book_Ticket(ticket) as StatusCodeResult;
            int t    = res1.StatusCode;

            Assert.AreEqual(201, t);
        }
Exemplo n.º 3
0
        public void Book_Ticket_Failure_Test()
        {
            Ticket ticket = new Ticket()
            {
                TicketId = 1, PassengerName = "Ram", FlightId = 4, StartingLocation = "Pune", Destination = "Agra", DateOfJourney = new System.DateTime(2020, 11, 24)
            };

            Mock <ITicketBookingRepo> bookrepo = new Mock <ITicketBookingRepo>();

            bookrepo.Setup(x => x.BookTicket(It.IsAny <Ticket>())).Returns(false);
            controller = new TicketController(bookrepo.Object);
            var res1 = controller.Book_Ticket(ticket) as StatusCodeResult;

            Assert.AreEqual(204, res1.StatusCode);
        }