Example #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);
        }
Example #2
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);
        }
Example #3
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);
        }
Example #4
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()]);
            };
        }