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); }
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()); }
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); }
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); }
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); }
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); }
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); }
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()]); }; }
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); }
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); }
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); }
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); }
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); }
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); }
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); }