示例#1
0
        public void CopyConstructor_MakingObject_ShouldPass()
        {
            // Arrange
            Flight flight = new Flight(info.AirlineName, info.OriginatingAirport, info.DestinationAirport, info.FlightNumber, info.DepartureDate);

            flight.AddFlightSection(section1);
            flight.AddFlightSection(section2);
            flight.AddFlightSection(section3);

            // Act
            Flight flightCopy = new Flight(flight);

            bool HasSameSequentialElements = true;

            for (int i = 0; i < flightCopy.FlightSections.Count; i++)
            {
                if (flight.FlightSections[i] != flightCopy.FlightSections[i])
                {
                    HasSameSequentialElements = false;
                    break;
                }
            }

            // Assert
            Assert.Equal(flight.Information.AirlineName, flightCopy.Information.AirlineName);
            Assert.Equal(flight.Information.OriginatingAirport, flightCopy.Information.OriginatingAirport);
            Assert.Equal(flight.Information.DestinationAirport, flightCopy.Information.DestinationAirport);
            Assert.Equal(flight.Information.DepartureDate, flightCopy.Information.DepartureDate);
            Assert.Equal(flight.Information.Id, flightCopy.Information.Id);
            Assert.Equal(flight.FlightSections.Count, flightCopy.FlightSections.Count);
            Assert.True(HasSameSequentialElements);
        }
示例#2
0
        public void AddFlightSection_AddingTwoDifferentFlightSections_ShouldPassTest()
        {
            // Arrange

            // Act
            Flight actual = new Flight(info.AirlineName, info.OriginatingAirport, info.DestinationAirport, info.FlightNumber, info.DepartureDate);

            actual.AddFlightSection(section1);
            actual.AddFlightSection(section2);

            // Assert
            Assert.NotNull(actual.FlightSections);
            Assert.Equal(2, actual.FlightSections.Count);
        }
示例#3
0
        public void AddFlightSection_AddingTwoExactFlightSections_ShouldPassTest()
        {
            // Arrange
            FlightOperation expected = FlightOperation.InvalidSectionAlreadyExistsFailure;
            Flight          flight   = new Flight(info.AirlineName, info.OriginatingAirport, info.DestinationAirport, info.FlightNumber, info.DepartureDate);

            flight.AddFlightSection(section1);

            // Act
            FlightOperation actual = flight.AddFlightSection(section1);

            // Assert
            Assert.Equal(expected, actual);
        }
示例#4
0
        public void addFlightSectionTest()
        {
            //Arrange
            Airline       airline     = new Airline("ABC");
            Airport       origin      = new Airport("HAM");
            Airport       destination = new Airport("DAM");
            Flight        flight      = new Flight(airline, origin, destination, 2020, 8, 13, "123");
            FlightSection section     = new FlightSection(SeatClass.Business, 5, 5);
            //Act
            var actual = flight.AddFlightSection(section); //ok

            flight.AddFlightSection(section);              //throws exception because the section is already in
            //Assert
            Assert.AreEqual(actual, true);
        }
示例#5
0
        public void bookingTest()
        {
            //Arrange
            Airline       airline     = new Airline("ABC");
            Airport       origin      = new Airport("HAM");
            Airport       destination = new Airport("DAM");
            Flight        flight      = new Flight(airline, origin, destination, 2020, 8, 13, "123");
            FlightSection section     = new FlightSection(SeatClass.Business, 1, 1);

            flight.AddFlightSection(section);
            //Act
            var actual  = flight.BookSeat(SeatClass.Business, 1, 'A');
            var actual1 = flight.BookSeat(SeatClass.Business, 1, 'A'); //tries to book already booked seat
            var actual2 = flight.BookSeat(SeatClass.Economy, 2, 'C');  //tries to book non existing seat

            //Assert
            Assert.AreEqual(true, actual);
            Assert.AreEqual(false, actual1);
            Assert.AreEqual(false, actual2);
        }
示例#6
0
        public void availableSeatsTest()
        {
            //Arrange
            Airline       airline     = new Airline("ABC");
            Airport       origin      = new Airport("HAM");
            Airport       destination = new Airport("DAM");
            Flight        flight      = new Flight(airline, origin, destination, 2020, 8, 13, "123");
            FlightSection section     = new FlightSection(SeatClass.Business, 1, 1);

            flight.AddFlightSection(section);
            //Act
            var actual = flight.hasAvailableSeats();     //true becuse there is one seat available

            flight.BookSeat(SeatClass.Business, 1, 'A'); //books the only avaiable seat
            var actual1 = flight.hasAvailableSeats();    //

            //Assert
            Assert.AreEqual(true, actual);
            Assert.AreEqual(false, actual1);
        }