示例#1
0
        public void Test_Find()
        {
            City newCity = new City("Atlanta");

            newCity.Save();

            City foundCity = City.Find(newCity.GetId());

            Assert.Equal(newCity, foundCity);
        }
示例#2
0
        public void TEST_SaveCityToDB()
        {
            List <City> totalCitys = new List <City> {
            };
            City tempCity          = new City("Seattle");

            totalCitys.Add(tempCity);

            tempCity.Save();
            Assert.Equal(totalCitys, City.GetAll());
        }
示例#3
0
        public void TEST_FindMethodReturnsSameCity()
        {
            City tempCity = new City("Seattle");

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

            City testCity = City.Find(tempCity.GetId());

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

            Assert.Equal(tempCity, testCity);
        }
示例#4
0
        public void Test_Find_ReturnCityFromDatabase()
        {
            //Arrange
            City testCity = new City("Seattle");

            testCity.Save();

            //Act
            City foundCity = City.Find(testCity.GetId());

            //Assert
            Assert.Equal(testCity, foundCity);
        }
示例#5
0
        public void Test_Delete()
        {
            City newCity = new City("Atlanta");

            newCity.Save();

            newCity.Delete();

            List <City> expected = new List <City> {
            };
            List <City> actual   = City.GetAll();

            //Assert
            Assert.Equal(expected, actual);
        }
示例#6
0
        public void Test_Save()
        {
            //Arrange, Act
            City newCity = new City("Atlanta");

            newCity.Save();

            List <City> expected = new List <City> {
                newCity
            };
            List <City> actual = City.GetAll();

            //Assert
            Assert.Equal(expected, actual);
        }
示例#7
0
        public void Test_Save_AssignedIdtoCity()
        {
            //Arrange
            City testCity = new City("Seattle");

            testCity.Save();
            City savedCity = City.GetAll()[0];

            //Act
            int savedId = savedCity.GetId();
            int testId  = testCity.GetId();

            //Assert
            Assert.Equal(testId, savedId);
        }
示例#8
0
        public void Test_Save_SavesToDatabase()
        {
            //Arrange
            City testCity = new City("Seattle");

            //Act
            testCity.Save();
            List <City> actualResult   = City.GetAll();
            List <City> expectedResult = new List <City> {
                testCity
            };

            //Assert
            Assert.Equal(expectedResult, actualResult);
        }
示例#9
0
        public void Test_GetAll_ReturnsListofCities()
        {
            //Arrange
            City firstCity  = new City("Seattle");
            City secondCity = new City("Portland");

            //Act
            firstCity.Save();
            secondCity.Save();

            //Assert
            List <City> actualResult   = City.GetAll();
            List <City> expectedResult = new List <City> {
                secondCity, firstCity
            };

            Assert.Equal(expectedResult, actualResult);
        }
示例#10
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()]);
            };
        }
示例#11
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);
        }
示例#12
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);
        }
示例#13
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);
        }
示例#14
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);
        }