Esempio n. 1
0
        public void Test_Find()
        {
            Flight newFlight = new Flight("1", "On time", "6:30 PM");

            newFlight.Save();

            Flight result = Flight.Find(newFlight.GetId());

            Assert.Equal(newFlight, result);
        }
Esempio n. 2
0
        public void Test_Save_CheckFlightSaveToDB()
        {
            List <Flight> totalFlights = new List <Flight> {
            };
            Flight tempFlight          = new Flight("complete", "5 am", "seattle", "los angeles");

            totalFlights.Add(tempFlight);

            tempFlight.Save();
            Assert.Equal(totalFlights, Flight.GetAll());
        }
Esempio n. 3
0
        public void TEST_FindMethodReturnsSameObject()
        {
            Flight tempFlight = new Flight("complete", "5 am", "seattle", "los angeles");

            tempFlight.Save();
            // Console.WriteLine(tempFlight.GetDestinationCity());

            Flight testFlight = Flight.Find(tempFlight.GetId());

            // Console.WriteLine(testFlight.GetDestinationCity());

            Assert.Equal(tempFlight, testFlight);
        }
Esempio n. 4
0
        public void Test_Delete()
        {
            Flight newFlight = new Flight("1", "On time", "6:30 PM");

            newFlight.Save();
            List <Flight> expected = new List <Flight> {
            };

            newFlight.Delete();
            List <Flight> actual = Flight.GetAll();

            Assert.Equal(expected, actual);
        }
Esempio n. 5
0
        public void Test_Find_ReturnFlightFromDatabase()
        {
            //Arrange
            DateTime departureTime = new DateTime(2017, 3, 14, 9, 30, 0);
            string   flightStatus  = "On Time";
            Flight   testFlight    = new Flight("AX5390", departureTime, flightStatus);

            testFlight.Save();

            //Act
            Flight foundFlight = Flight.Find(testFlight.GetId());

            //Assert
            Assert.Equal(testFlight, foundFlight);
        }
Esempio n. 6
0
        public void Test_Save_AssignedIdtoFlight()
        {
            //Arrange
            DateTime departureTime = new DateTime(2017, 3, 14, 9, 30, 0);
            string   flightStatus  = "On Time";
            Flight   testFlight    = new Flight("AX5390", departureTime, flightStatus);

            testFlight.Save();
            Flight savedFlight = Flight.GetAll()[0];

            //Act
            int savedId = savedFlight.GetId();
            int testId  = testFlight.GetId();

            //Assert
            Assert.Equal(testId, savedId);
        }
Esempio n. 7
0
        public void Test_Save_SavesToDatabase()
        {
            //Arrange
            DateTime departureTime = new DateTime(2017, 3, 14, 9, 30, 0);
            string   flightStatus  = "On Time";
            Flight   testFlight    = new Flight("AX5390", departureTime, flightStatus);

            testFlight.Save();

            //Act
            List <Flight> resultList = Flight.GetAll();
            List <Flight> testList   = new List <Flight> {
                testFlight
            };

            //Assert
            Assert.Equal(testList, resultList);
        }
Esempio n. 8
0
        public HomeModule()
        {
            Get["/"] = _ => {
                return(View["index.cshtml", ModelMaker()]);
            };

            Get["/add-cities"] = _ => {
                return(View["add-cities.cshtml"]);
            };

            Post["/add-cities"] = _ => {
                City newCity = new City(Request.Form["city-name"]);
                newCity.Save();
                return(View["index.cshtml", ModelMaker()]);
            };

            Get["/add-flights"] = _ => {
                return(View["add-flights.cshtml", ModelMaker()]);
            };

            Post["/add-flights"] = _ => {
                Flight newFlight = new Flight(Request.Form["flight-num"], Request.Form["flight-status"], Request.Form["flight-time"]);
                newFlight.Save();

                City departureCity = City.Find(Request.Form["departure"]);
                City arrivalCity   = City.Find(Request.Form["arrival"]);

                newFlight.AddFlight(departureCity, arrivalCity);

                return(View["index.cshtml", ModelMaker()]);
            };

            Delete["/delete/{id}"] = parameters => {
                Flight.Find(parameters.id).Delete();
                return(View["index.cshtml", ModelMaker()]);
            };

            Patch["/edit/{id}"] = parameters => {
                Flight.Find(parameters.id).EditStatus(Request.Form["status"]);
                return(View["index.cshtml", ModelMaker()]);
            };
        }
Esempio n. 9
0
        public void Test_DeleteThisFlight_OneFlightDeletedFromDatabase()
        {//Arrange
            DateTime departureTime = new DateTime(2017, 3, 14, 9, 30, 0);
            string   flightStatus  = "On Time";
            Flight   firstFlight   = new Flight("AX5390", departureTime, flightStatus);
            Flight   secondFlight  = new Flight("BD890", departureTime, flightStatus);

            firstFlight.Save();
            secondFlight.Save();

            //Act
            firstFlight.DeleteThisFlight();
            List <Flight> result = Flight.GetAll();
            List <Flight> verify = new List <Flight> {
                secondFlight
            };

            //Assert
            Assert.Equal(verify, result);
        }
Esempio n. 10
0
        public void TestAddCitiesToFlightAndFindFlight()
        {
            Flight newFlight = new Flight("1", "On time", "6:30 PM");

            newFlight.Save();
            City departure = new City("Atlanta");

            departure.Save();
            City arrival = new City("New York");

            arrival.Save();

            newFlight.AddFlight(departure, arrival);
            List <City> expected = new List <City>();

            expected.Add(departure);
            expected.Add(arrival);
            List <City> actual = newFlight.GetCities();

            Assert.Equal(expected, actual);
        }
Esempio n. 11
0
        public void Test_GetAll_ReturnsListofFlights()
        {
            //Arrange
            DateTime firstDepartureTime  = new DateTime(2017, 3, 14, 9, 30, 0);
            DateTime secondDepartureTime = new DateTime(2007, 3, 14, 9, 30, 0);
            string   flightStatus        = "On Time";
            Flight   firstFlight         = new Flight("AX5390", firstDepartureTime, flightStatus);
            Flight   secondFlight        = new Flight("B45390", secondDepartureTime, flightStatus);

            //Act
            firstFlight.Save();
            secondFlight.Save();

            //Assert
            List <Flight> actualResult   = Flight.GetAll();
            List <Flight> expectedResult = new List <Flight> {
                secondFlight, firstFlight
            };

            Assert.Equal(expectedResult, actualResult);
        }
Esempio n. 12
0
        public void Test_Update_UpdatesFlightStatusinDB()
        {
            //Arrange
            DateTime departureTime = new DateTime(2017, 3, 14, 9, 30, 0);
            string   flightStatus  = "On Time";
            Flight   testFlight    = new Flight("AX5390", departureTime, flightStatus);

            testFlight.Save();

            string newFlightStatus = "Delayed";

            //Act
            testFlight.UpdateStatus(newFlightStatus);


            //Assert
            string actualResult   = testFlight.GetStatus();
            string expectedResult = newFlightStatus;

            Assert.Equal(expectedResult, actualResult);
        }
Esempio n. 13
0
        public void Test_GetCities_GatAllCities()
        {
            Flight testFlight = new Flight("complete", "5 am", "seattle", "los angeles");

            testFlight.Save();

            City city1 = new City("LA");

            city1.Save();

            City city2 = new City("SJ");

            city2.Save();

            testFlight.AddCity(city1);
            List <City> savedCities = testFlight.GetCities();
            List <City> testList    = new List <City> {
                city1
            };

            Assert.Equal(savedCities, testList);
        }
Esempio n. 14
0
        public void Test_AddCity_AddCityToFlight()
        {
            Flight testFlight = new Flight("complete", "5 am", "seattle", "los angeles");

            testFlight.Save();

            City city1 = new City("LA");

            city1.Save();

            City city2 = new City("SJ");

            city2.Save();

            testFlight.AddCity(city1);
            testFlight.AddCity(city2);

            List <City> testList = new List <City> {
                city1, city2
            };
            List <City> result = testFlight.GetCities();

            Assert.Equal(testList, result);
        }
Esempio n. 15
0
        public void Test_AddDepartureCity_AddsDepartureCityToFlight()
        {
            //Arrange
            DateTime departureTime = new DateTime(2017, 3, 14, 9, 30, 0);
            string   flightStatus  = "On Time";
            Flight   testFlight    = new Flight("AX5390", departureTime, flightStatus);

            testFlight.Save();

            City departureCity = new City("Seattle");

            departureCity.Save();

            //Act
            testFlight.AddDepartureCity(departureCity);

            List <City> result   = testFlight.GetDepartureCity();
            List <City> testList = new List <City> {
                departureCity
            };

            //Assert
            Assert.Equal(testList, result);
        }