示例#1
0
        private void Add_element_from_create_page()
        {
            //Arrange
            this._model = CityFactory.GetCity(CityType.Paris);

            // Act
            this._controller.Create(this._model);
        }
示例#2
0
        private void Edit_added_element()
        {
            //Arrange

            // Act
            this._model.Name = CityFactory.GetCity(CityType.NewYork).Name;
            this._controller.Edit(this._model);
        }
示例#3
0
        private void Check_details_of_the_edited_city()
        {
            //Arrange

            // Act
            ViewResult result      = this._controller.Details(this._model.Id) as ViewResult;
            var        detailsCity = result.Model as City;

            // Assert
            Assert.IsNotNull(result);
            Assert.IsNotNull(detailsCity);
            Assert.AreEqual(detailsCity.Name, CityFactory.GetCity(CityType.NewYork).Name);
            Assert.AreEqual(detailsCity.Location.Description, this._model.Location.Description);
            Assert.AreEqual("Details", result.ViewName);
        }
示例#4
0
        public void Should_Get_Two_Cities()
        {
            using (var session = this._cityUnit.GetSession())
            {
                var citiesRepo  = session.GetRepository();
                var citiesCount = citiesRepo.GetAll().Count();
                var paris       = CityFactory.GetCity(CityType.Paris);
                var newYork     = CityFactory.GetCity(CityType.NewYork);


                citiesRepo.AddRange(new[] { newYork, paris });
                session.Complete();

                Assert.AreEqual(citiesCount + 2, citiesRepo.GetAll().Count());
            }
        }
示例#5
0
        public void Should_Get_One_Recorded_city_in_report_history_when_add_city_from_tracking_unit()
        {
            using (var session = this._cityUniTracker.GetSession())
            {
                var repo = session.GetRepository();
                repo.Add(CityFactory.GetCity(CityType.Melbourne));
                session.Complete();
            }

            using (var session = this._historyLineUnit.GetSession())
            {
                var historyLineRepo = session.GetRepository();
                var historyLines    = historyLineRepo.GetAll();

                Assert.AreEqual(1, historyLines.Count());
                Assert.AreEqual(typeof(City).Name, historyLines.First().DateType);
                Assert.AreEqual(OperationType.Create, historyLines.First().Operation);
            }
        }
示例#6
0
 private static Airport GetPudong()
 {
     return(new Airport(31.1443439, 121.80827299999999, @"Pudong Airport", CityFactory.GetCity(CityType.Shanghai)));
 }
示例#7
0
 private static Airport GetGimpo()
 {
     return(new Airport(-37.814107, 144.96328, @"Gimpo Airport", CityFactory.GetCity(CityType.Seoul)));
 }
示例#8
0
 private static Airport GetOrly()
 {
     return(new Airport(48.856614, 2.3522219, @"Orly Airport", CityFactory.GetCity(CityType.Paris)));
 }
示例#9
0
 private static Airport GetBeijing()
 {
     return(new Airport(40.0798573, 116.60311209999998, @"Beijing Capital International  Airport", CityFactory.GetCity(CityType.Beijing)));
 }
示例#10
0
 private static Airport GetIncheon()
 {
     return(new Airport(37.460191, 126.440696, @"Incheon Airport", CityFactory.GetCity(CityType.Seoul)));
 }
示例#11
0
 private static Airport GetCalcutta()
 {
     return(new Airport(22.6520429, 88.4463299, @"Netaji Subhas Chandra Bose International Airport", CityFactory.GetCity(CityType.Calcutta)));
 }
示例#12
0
 private static Airport GetMelbourne()
 {
     return(new Airport(-37.669012, 144.841027, @"Melbourne Airport", CityFactory.GetCity(CityType.Melbourne)));
 }
示例#13
0
 private static Airport GetCDG()
 {
     return(new Airport(49.0096906, 2.547924500000022, @"Charles de Gaulle Airport", CityFactory.GetCity(CityType.Paris)));
 }
示例#14
0
 private static Airport GetJfk()
 {
     return(new Airport(40.7127753, -74.0059728, @"JFK Airport", CityFactory.GetCity(CityType.NewYork)));
 }
示例#15
0
 private static Airport GetBuenosAires()
 {
     return(new Airport(-34.598326, -58.375275, @"Buenos Aires Airport", CityFactory.GetCity(CityType.BuenosAires)));
 }
示例#16
0
 private static Airport GetNewyark()
 {
     return(new Airport(40.4325, 13.404953999999975, @"Newwark Airport", CityFactory.GetCity(CityType.NewJersey)));
 }
示例#17
0
 private static Airport GetBerlin()
 {
     return(new Airport(52.52000659999999, 13.404953999999975, @"Berlin Airport", CityFactory.GetCity(CityType.Berlin)));
 }
示例#18
0
        //the database context object as an input parameter
        protected override void Seed(TuiContext context)
        {
            var cities = new List <City>();

            cities.AddRange(new[]
            {
                CityFactory.GetCity(CityType.NewYork),
                CityFactory.GetCity(CityType.Paris),
                CityFactory.GetCity(CityType.Berlin),
                CityFactory.GetCity(CityType.NewJersey),
                CityFactory.GetCity(CityType.Shanghai),
                CityFactory.GetCity(CityType.Beijing),
                CityFactory.GetCity(CityType.Seoul),
                CityFactory.GetCity(CityType.BuenosAires),
                CityFactory.GetCity(CityType.Calcutta),
                CityFactory.GetCity(CityType.Melbourne)
            }
                            );

            cities.ForEach(s => context.Cities.Add(s));

            var airports = new List <Airport>();

            airports.Add(AirportFactory.GetAirport(AirportType.Orly));
            airports.Add(AirportFactory.GetAirport(AirportType.CharlesDeGaule));
            airports.Add(AirportFactory.GetAirport(AirportType.JFK));
            airports.Add(AirportFactory.GetAirport(AirportType.berlin));
            airports.Add(AirportFactory.GetAirport(AirportType.Newwark));
            airports.Add(AirportFactory.GetAirport(AirportType.BuenosAires));
            airports.Add(AirportFactory.GetAirport(AirportType.Pudong));
            airports.Add(AirportFactory.GetAirport(AirportType.Hongqiao));
            airports.Add(AirportFactory.GetAirport(AirportType.Netaji));
            airports.Add(AirportFactory.GetAirport(AirportType.Melbourne));
            airports.Add(AirportFactory.GetAirport(AirportType.Beijing));
            airports.Add(AirportFactory.GetAirport(AirportType.Incheon));
            airports.Add(AirportFactory.GetAirport(AirportType.Gimpo));

            //overwrite city reference
            foreach (var airport in airports)
            {
                if (cities.Any(c => airport.City.Name == c.Name))
                {
                    airport.City = cities.Find(c => airport.City.Name == c.Name);
                }
            }

            airports.ForEach(s => context.Airports.Add(s));

            var gasKind    = GasFactory.GetJetFuel();
            var airbusKind = PlaneKindFactory.GetPlane(PlaneType.airbus);
            var boeingKind = PlaneKindFactory.GetPlane(PlaneType.boeing);

            var flights = new List <Flight>();

            flights.Add(new Flight()
            {
                Plane = new Plane()
                {
                    Kind = airbusKind, GasKind = gasKind
                },
                DepartureAirport = airports[0],
                ArrivalAirport   = airports[3],
                StartDate        = new DateTime(2001, 6, 6, 10, 15, 0)
            });

            flights.Add(new Flight()
            {
                Plane = new Plane()
                {
                    Kind = boeingKind, GasKind = gasKind
                },
                DepartureAirport = airports[2],
                ArrivalAirport   = airports[7],
                StartDate        = new DateTime(2001, 6, 18, 10, 35, 0)
            });

            flights.Add(new Flight()
            {
                Plane = new Plane()
                {
                    Kind = airbusKind, GasKind = gasKind
                },
                DepartureAirport = airports[0],
                ArrivalAirport   = airports[3],
                StartDate        = new DateTime(2001, 6, 9, 13, 15, 0)
            });

            flights.Add(new Flight()
            {
                Plane = new Plane()
                {
                    Kind = boeingKind, GasKind = gasKind
                },
                DepartureAirport = airports[2],
                ArrivalAirport   = airports[1],
                StartDate        = new DateTime(2001, 6, 8, 11, 15, 0)
            });

            flights.ForEach(s => context.Flights.Add(s));
            context.SaveChanges();

            context.Users.Add(new Login.source.User()
            {
                Name = "bob", Password = "******"
            });
            context.SaveChanges();

            base.Seed(context);
        }
示例#19
0
 private static Airport GetHongqiao()
 {
     return(new Airport(31.192209, 121.334297, @"Hongqiao Airport", CityFactory.GetCity(CityType.Shanghai)));
 }