Example #1
0
        public void AircraftWith1MaximumPassenger_ShouldntSetMoreThan1Person()
        {
            // Création de deux comptes
            Person person_1 = CreatePerson("test", "test", "*****@*****.**");
            Person person_2 = CreatePerson("test", "test", "*****@*****.**");

            // Capacité maximale à 1 personne
            Aircraft aircraft  = new Aircraft("test", 500, 35, 100, new TimeSpan(2, 0, 0), 1);
            Airport  airport_1 = new Airport("test", "France", 1.0, 1.0);
            Airport  airport_2 = new Airport("test_2", "France", 2.0, 2.0);

            Flight flight = new Flight(airport_1, airport_2);

            // On contourne la réservation de l'avion pour ce test
            flight.Aircraft = aircraft;
            flight.AddPerson(person_1.Id);
            Assert.False(flight.AddPerson(person_2.Id));
        }
Example #2
0
        public Flight SetPeople(Flight flight, FlightsViewModel flightsViewModel, Guid aircraftGuid)
        {
            flight.Aircraft = _context.Aircrafts.FirstOrDefault(s => s.Id == aircraftGuid);
            if (flightsViewModel.PeopleIds != null)
            {
                flightsViewModel.PeopleIds.ForEach(s => {
                    if (!flight.AddPerson(s))
                    {
                        throw new Exception("Limit excedeed !");
                    }
                });
            }

            return(flight);
        }