public void AddDeletePlaneType_Returns_CreatedResult_And_PlaneType_ShoudBe_AddedTo_Database_And_Then_ShouldBe_Deleted()
        {
            // Arrange
            MSSQLContext         context = new MSSQLContext();
            PlaneTypesRepository planeTypesRepository = new PlaneTypesRepository();
            PlanesRepository     planesRepository     = new PlanesRepository();
            AircraftUnitOfWork   uow        = new AircraftUnitOfWork(planesRepository, planeTypesRepository, context);
            AircraftService      service    = new AircraftService(uow);
            PlaneTypesController controller = new PlaneTypesController(mapper.GetDefaultMapper(), service);

            // add act
            var newPlaneTypeDTO = new PlaneTypeDTO()
            {
                Capacity      = 100,
                CargoCapacity = 5000,
                Model         = "Hurricane"
            };

            var addResult = controller.AddPlaneType(newPlaneTypeDTO);

            // add assert
            Assert.IsInstanceOf <CreatedResult>(addResult);
            Assert.IsInstanceOf <PlaneTypeDTO>((addResult as CreatedResult).Value);

            // delete act
            var addedPlaneTypeDTO = (addResult as CreatedResult).Value as PlaneTypeDTO;
            var deleteResult      = controller.DeletePlaneType(addedPlaneTypeDTO.Id);

            // delete assert
            Assert.IsInstanceOf <OkResult>(deleteResult);
            Assert.IsInstanceOf <NotFoundObjectResult>(controller.GetPlaneType(addedPlaneTypeDTO.Id));
        }
Exemplo n.º 2
0
        public void TestSetup()
        {
            _aircraftId = 1;
            _plane1     = new Aircraft()
            {
                Id           = _aircraftId, AircraftName = "Strong",
                AircraftType = new AircraftType()
                {
                    Id = 1, AircraftModel = "Tupolev Tu-134", SeatsNumber = 80, Carrying = 47000
                },
                AircraftReleaseDate = new DateTime(2011, 6, 10), ExploitationTimeSpan = new DateTime(2021, 6, 10) - new DateTime(2011, 6, 10)
            };

            _plane1DTO = new DTO.Aircraft
            {
                Id           = _aircraftId, AircraftName = "Strong",
                AircraftType = new DTO.AircraftType()
                {
                    Id = 1, AircraftModel = "Tupolev Tu-134", SeatsNumber = 80, Carrying = 47000
                },
                AircraftReleaseDate = new DateTime(2011, 6, 10), ExploitationTimeSpan = new DateTime(2021, 6, 10) - new DateTime(2011, 6, 10)
            };

            A.CallTo(() => _fakeMapper.Map <Aircraft, DTO.Aircraft>(_plane1)).Returns(_plane1DTO);
            A.CallTo(() => _fakeMapper.Map <DTO.Aircraft, Aircraft>(_plane1DTO)).Returns(_plane1);

            A.CallTo(() => _fakeUnitOfWork.AircraftRepository).Returns(_fakeAircraftRepository);
            A.CallTo(() => _fakeUnitOfWork.Set <AircraftType>()).Returns(_fakeAircraftTypeRepository);
            _aircraftService = new AircraftService(_fakeUnitOfWork, _fakeMapper);
        }
Exemplo n.º 3
0
        public void When_Relaxed_Rule_Is_Used_Should_Proceed_With_Flight()
        {
            var passengerService = new PassengerService();
            var aircraftService  = new AircraftService();

            aircraftService.AddPlanes(TestData.SmallAntonovPlane);
            var calculationService = new CalculationService();

            calculationService.AddRules(new ProfitRule(), new RelaxedRule());
            var flightService   = new FlightService(TestData.LondonToParis);
            var scheduledFlight = new ScheduledFlight(
                flightService,
                passengerService,
                aircraftService,
                calculationService,
                new SummaryFormat(passengerService, aircraftService));

            scheduledFlight.SetAircraftForRoute(122);

            scheduledFlight.SetCurrentRule <RelaxedRule>();

            scheduledFlight.AddPassenger(TestData.JackLoyaltyPassenger);
            scheduledFlight.AddPassenger(TestData.TrevorAirlineEmployeePassenger);
            scheduledFlight.AddPassenger(TestData.SunnyAirlineEmployeePassenger);
            scheduledFlight.AddPassenger(TestData.SunnyAirlineEmployeePassenger);
            scheduledFlight.AddPassenger(TestData.MartinAirlineEmployeePassenger);
            scheduledFlight.AddPassenger(TestData.MartinAirlineEmployeePassenger);
            scheduledFlight.AddPassenger(TestData.MikeDiscountedPassenger);

            scheduledFlight.Process();

            Assert.True(flightService.CanFlightProceed);
            Assert.Equal(-200, flightService.ProfitSurplus);
        }
Exemplo n.º 4
0
        public void AllOnesReturnsOneDay()
        {
            var compare = 1.0;
            var actual  = AircraftService.FindDaysByHours(1, 1, 1, 1);

            Assert.Equal(actual, compare);
        }
        public void AddDeletePlane_Returns_CreatedResult_And_Plane_ShoudBe_AddedTo_Database_And_Then_ShouldBe_Deleted()
        {
            // Arrange
            MSSQLContext         context = new MSSQLContext();
            PlaneTypesRepository planeTypesRepository = new PlaneTypesRepository();
            PlanesRepository     planesRepository     = new PlanesRepository();
            AircraftUnitOfWork   uow        = new AircraftUnitOfWork(planesRepository, planeTypesRepository, context);
            AircraftService      service    = new AircraftService(uow);
            PlanesController     controller = new PlanesController(mapper.GetDefaultMapper(), service);

            // add act
            var newPlaneDTO = new PlaneDTO()
            {
                Lifetime             = new TimeSpan(200, 0, 0, 0, 0),
                Name                 = "Bf-109g",
                ReleaseDate          = new DateTime(1941, 1, 1, 0, 0, 0),
                FlightHours          = 560,
                LastHeavyMaintenance = DateTime.Now,
                PlaneTypeId          = 1
            };

            var addResult = controller.AddPlane(newPlaneDTO);

            // add assert
            Assert.IsInstanceOf <CreatedResult>(addResult);
            Assert.IsInstanceOf <PlaneDTO>((addResult as CreatedResult).Value);

            // delete act
            var addedPlaneDTO = (addResult as CreatedResult).Value as PlaneDTO;
            var deleteResult  = controller.DeletePlane(addedPlaneDTO.Id);

            // delete assert
            Assert.IsInstanceOf <OkResult>(deleteResult);
            Assert.IsInstanceOf <NotFoundObjectResult>(controller.GetPlane(addedPlaneDTO.Id));
        }
Exemplo n.º 6
0
        public void AddingOneMonthReturnsMaySeventh()
        {
            var date    = DateTime.Parse("2018-04-07T00:00:00");
            var compare = DateTime.Parse("2018-05-07T00:00:00");
            var actual  = AircraftService.FindNextMonthDue(date, 1);

            Assert.Equal(actual, compare);
        }
Exemplo n.º 7
0
        public void AddingOneDayReturnsAprilEighth()
        {
            var date    = DateTime.Parse("2018-04-07T00:00:00");
            var compare = DateTime.Parse("2018-04-08T00:00:00");
            var actual  = AircraftService.FindNextHoursDue(date, 1);

            Assert.Equal(actual, compare);
        }
        private AircraftModelDataGroup GetGroupFromModel(AircraftService.AircraftModel model)
        {
            AircraftModelDataGroup group = new AircraftModelDataGroup(
                model.ModelName, model.Caption, model.LastUsed.ToString("yyyy-MM-dd HH:mm:ss"), string.Empty,
                string.Empty);

            return group;
        }
Exemplo n.º 9
0
 public AircraftViewModel()
 {
     Title           = "Aircraft";
     AircraftService = new AircraftService();
     SearchFilter    = "";
     Aircrafts       = new ObservableCollection <Aircraft>();
     Aircraft        = new Aircraft();
     Search();
 }
Exemplo n.º 10
0
        public async Task Update_WhenAircraftNull_ThenReturnExeption()
        {
            var aircrafts = new IFakeRepository <Aircraft>();
            var context   = new IFakeUnitOfFactory();

            AircraftDto aircraftDto = null;

            AircraftService service          = new AircraftService(context);
            AircraftDto     aircraftDtoSaved = await service.Update(aircraftDto);
        }
Exemplo n.º 11
0
        public void SheduleDeleteDeparture_When_All_Args_IsOk_When_Should_Return_CreatedResult_And_Add_Departure_To_dB_And_Then_Delete()
        {
            // Arrange

            #region ControllerInit

            MSSQLContext         context = new MSSQLContext();
            PlaneTypesRepository planeTypesRepository = new PlaneTypesRepository();
            PlanesRepository     planesRepository     = new PlanesRepository();
            AircraftUnitOfWork   uow     = new AircraftUnitOfWork(planesRepository, planeTypesRepository, context);
            AircraftService      service = new AircraftService(uow);

            CrewsRepository        crewsRepository        = new CrewsRepository();
            PilotsRepository       pilotsRepository       = new PilotsRepository();
            StewardessesRepository stewardessesRepository = new StewardessesRepository();
            CrewingUnitOfWork      cuow           = new CrewingUnitOfWork(crewsRepository, pilotsRepository, stewardessesRepository, context);
            CrewingService         crewingService = new CrewingService(cuow);

            FlightsRepository          flightRepository     = new FlightsRepository();
            DeparturesRepository       departuresRepository = new DeparturesRepository();
            TicketsRepository          ticketsRepository    = new TicketsRepository();
            FlightOperationsUnitOfWork flightOpUow          = new FlightOperationsUnitOfWork(flightRepository, ticketsRepository, departuresRepository, context);
            FlightOperationsService    flightOpeService     = new FlightOperationsService(flightOpUow);

            AiroportService   airportService = new AiroportService(service, crewingService, flightOpeService);
            AirportController controller     = new AirportController(mapper.GetDefaultMapper(), airportService);

            #endregion

            var departureDto = new DepartureDTO()
            {
                CrewId        = crewId,
                DepartureTime = new DateTime(2018, 8, 10, 11, 0, 0),
                PlaneId       = 2,
                FlightId      = 1
            };

            var addResult = controller.SheduleDeparture(departureDto);

            // add assert
            Assert.IsInstanceOf <CreatedResult>(addResult);
            Assert.IsInstanceOf <DepartureDTO>((addResult as CreatedResult).Value);

            // delete act
            var addedDepartureDTO = (addResult as CreatedResult).Value as DepartureDTO;
            var deleteResult      = controller.DeleteDeparture(addedDepartureDTO.Id);
            // delete assert
            Assert.IsInstanceOf <OkResult>(deleteResult);

            Assert.IsNull(departuresRepository.Get(addedDepartureDTO.Id));
        }
Exemplo n.º 12
0
        public void Should_Return_Same_Data_When_Calling_Process_Twice()
        {
            var passengerService = new PassengerService();
            var aircraftService  = new AircraftService();

            aircraftService.AddPlanes(TestData.AntonovPlane);
            var calculationService = new CalculationService();

            calculationService.AddRules(new ProfitRule(), new RelaxedRule());
            var flightService   = new FlightService(TestData.LondonToParis);
            var scheduledFlight = new ScheduledFlight(
                flightService,
                passengerService,
                aircraftService,
                calculationService,
                new SummaryFormat(passengerService, aircraftService));

            scheduledFlight.SetAircraftForRoute(123);
            scheduledFlight.SetCurrentRule <ProfitRule>();

            scheduledFlight.AddPassenger(TestData.SteveGeneralPassenger);
            scheduledFlight.AddPassenger(TestData.MarkGeneralPassenger);
            scheduledFlight.AddPassenger(TestData.JamesGeneralPassenger);
            scheduledFlight.AddPassenger(TestData.JaneGeneralPassenger);
            scheduledFlight.AddPassenger(TestData.AlanGeneralPassenger);
            scheduledFlight.AddPassenger(TestData.SuzyGeneralPassenger);
            scheduledFlight.AddPassenger(TestData.AnthonyGeneralPassenger);
            scheduledFlight.AddPassenger(TestData.MikeGeneralPassenger);
            scheduledFlight.AddPassenger(TestData.JohnLoyaltyPassenger);
            scheduledFlight.AddPassenger(TestData.SarahLoyaltyPassenger);
            scheduledFlight.AddPassenger(TestData.JackLoyaltyPassenger);
            scheduledFlight.AddPassenger(TestData.TrevorAirlineEmployeePassenger);
            scheduledFlight.AddPassenger(TestData.MikeDiscountedPassenger);

            scheduledFlight.Process();
            scheduledFlight.Process();

            Assert.Equal(13, passengerService.GetCountForPassengerType <Passenger>());
            Assert.Equal(8, passengerService.GetCountForPassengerType <GeneralPassenger>());
            Assert.Equal(3, passengerService.GetCountForPassengerType <LoyaltyPassenger>());
            Assert.Equal(1, passengerService.GetCountForPassengerType <DiscountedPassenger>());
            Assert.Equal(1, passengerService.GetCountForPassengerType <AirlineEmployeePassenger>());

            Assert.Equal(15, flightService.TotalExpectedBaggage);
            Assert.Equal(1050, flightService.ProfitFromFlight);
            Assert.Equal(650, flightService.CostOfFlight);
            Assert.Equal(10, flightService.TotalLoyaltyPointsAccrued);
            Assert.Equal(100, flightService.TotalLoyaltyPointsRedeemed);
            Assert.Equal(400, flightService.ProfitSurplus);
        }
        public ItemDetailViewModel(Item item = null)
        {
            Title = item?.Text;
            Item  = item;

            this.StartFlightCommand = ReactiveCommand.CreateFromTask(async() =>
            {
                await AircraftService.ExecuteFlightPlan(Item, CancellationToken.Token);
            });

            this.EmergencyShutdownCommand = ReactiveCommand.Create(() =>
            {
                CancelToken();
                AircraftService.Shutdown();
                RefreshToken();
            });
        }
        public void TestSetup()
        {
            _plane = new DTO.Aircraft()
            {
                AircraftName = "StrongWind",
                AircraftType = new DTO.AircraftType()
                {
                    AircraftModel = "Tupolev Tu-134", SeatsNumber = 80, Carrying = 47000
                },
                AircraftReleaseDate  = new DateTime(2011, 6, 10),
                ExploitationTimeSpan = new DateTime(2021, 6, 10) - new DateTime(2011, 6, 10)
            };

            uow = new UnitOfWork(airportContext);
            var mapper = GetAutoMapperConfig().CreateMapper();

            _aircraftService = new AircraftService(uow, mapper);
        }
Exemplo n.º 15
0
        public async Task Update_WhenValidAircraft_ThenReturnAircraft()
        {
            var aircrafts = new IFakeRepository <Aircraft>();
            var context   = new IFakeUnitOfFactory();

            AircraftDto aircraftDto = new AircraftDto()
            {
                Id             = 154,
                AircraftName   = "Test",
                TypeAircraftId = 165
            };

            AircraftService service          = new AircraftService(context);
            AircraftDto     aircraftDtoSaved = await service.Update(aircraftDto);

            Assert.AreEqual(aircraftDto.AircraftName, aircraftDtoSaved.AircraftName);
            Assert.AreEqual(aircraftDto.Id, aircraftDtoSaved.Id);
            Assert.AreEqual(aircraftDto.TypeAircraftId, aircraftDtoSaved.TypeAircraftId);
        }
Exemplo n.º 16
0
        public void GetPlaneTechCondition_When_FlightHours_less_than_500_then_returns_None(int flightHours)
        {
            // Arrange
            var mock = new Mock <IDbAircraftUnitOfWork>();

            var service = new AircraftService(mock.Object);

            Plane plane = new Plane()
            {
                LastHeavyMaintenance = DateTime.Now - new TimeSpan(3000, 0, 0, 0),
                FlightHours          = flightHours
            };

            // Act
            var result = service.GetPlaneTechCondition(plane);

            // Assert
            Assert.AreEqual(CheckNeeded.None, result);
        }
Exemplo n.º 17
0
        public ActionResult GetAllAircraftsAsync(int day)
        {
            //Make sur to dispose all ressources event if
            using (AircraftService aircraftService = new AircraftService(_flightManagerDbContext))
            {
                //Call to the database
                var aircrafts = aircraftService.GetAllAvailableAircrafts(day);

                //Configure the serialization to send the json in CamelCase
                JsonSerializerSettings settings = new JsonSerializerSettings
                {
                    ContractResolver = new CamelCasePropertyNamesContractResolver()
                };
                //Json serialization
                string json = JsonConvert.SerializeObject(aircrafts, settings);

                //Return http request as OK with serialized aiport list
                return(Ok(json));
            }
        }
Exemplo n.º 18
0
        public void GetPlaneTechCondition_When_Since_LastHeavyMaintenanceDate_12Years_passed_then_returns_D_Check(int yearsCount)
        {
            // Arrange
            var mock = new Mock <IDbAircraftUnitOfWork>();

            mock.SetReturnsDefault <object>(null);

            var service = new AircraftService(mock.Object);

            Plane plane = new Plane()
            {
                FlightHours          = 8000,
                LastHeavyMaintenance = DateTime.Now - new TimeSpan(365 * yearsCount, 0, 0, 0, 0)
            };

            // Act
            var result = service.GetPlaneTechCondition(plane);

            // Assert
            Assert.AreEqual(CheckNeeded.D_Check, result);
        }
Exemplo n.º 19
0
        public void GetPlaneTechCondition_When_FlightHours_greaterOrEqual_7500_then_returns_C_Check(int flightHours)
        {
            // Arrange
            var mock = new Mock <IDbAircraftUnitOfWork>();

            mock.SetReturnsDefault <object>(null);

            var service = new AircraftService(mock.Object);

            Plane plane = new Plane()
            {
                LastHeavyMaintenance = DateTime.Now - new TimeSpan(3000, 0, 0, 0),
                FlightHours          = flightHours
            };

            // Act
            var result = service.GetPlaneTechCondition(plane);

            // Assert
            Assert.AreEqual(CheckNeeded.C_Check, result);
        }
Exemplo n.º 20
0
 internal static FlightDataEntitiesRT.Decisions.FlightConditionDecision FromAircraftService(AircraftService.FlightConditionDecision one)
 {
     var decisions = new FlightDataEntitiesRT.Decisions.FlightConditionDecision()
     {
         DecisionID = one.DecisionID,
         DecisionName = one.DecisionName,
         EventLevel = one.EventLevel,
         LastTime = one.LastTime,
         RelatedParameters = one.RelatedParameters.ToArray(),
         DecisionDescriptionStringTemplate = one.DecisionDescriptionStringTemplate,
         Conditions =
         (from two in one.Conditions
          select RTConverter.FromAircraftService(two)).ToArray()
     };
     return decisions;
 }
Exemplo n.º 21
0
 public static FlightDataEntitiesRT.Decisions.SubCondition FromAircraftService(AircraftService.SubCondition two)
 {
     if (two.ConditionType == AircraftService.SubConditionType.DeltaRate)
     {
         return new FlightDataEntitiesRT.Decisions.DeltaRateSubCondition()
         {
             Operator = FromAircraftService(two.Operator),
             ParameterID = two.ParameterID,
             ParameterValue = two.ParameterValue,
             Relation = FromAircraftService(two.Relation),
             SubConditions = two.SubConditions == null ? null :
                             (from three in two.SubConditions
                              select RTConverter.FromAircraftService(three)).ToArray()
         };
     }
     else
     {
         return new FlightDataEntitiesRT.Decisions.CompareSubCondition()
         {
             Operator = FromAircraftService(two.Operator),
             ParameterID = two.ParameterID,
             ParameterValue = two.ParameterValue,
             Relation = FromAircraftService(two.Relation),
             SubConditions = two.SubConditions == null ? null :
                             (from three in two.SubConditions
                              select RTConverter.FromAircraftService(three)).ToArray()
         };
     }
 }
Exemplo n.º 22
0
        public void Ensure_That_Original_Use_Case_Works()
        {
            var passengerService = new PassengerService();
            var aircraftService  = new AircraftService();

            aircraftService.AddPlanes(TestData.AntonovPlane);
            var calculationService = new CalculationService();

            calculationService.AddRules(new ProfitRule(), new RelaxedRule());
            var flightService   = new FlightService(TestData.LondonToParis);
            var scheduledFlight = new ScheduledFlight(
                flightService,
                passengerService,
                aircraftService,
                calculationService,
                new SummaryFormat(passengerService, aircraftService));

            scheduledFlight.SetAircraftForRoute(123);
            scheduledFlight.SetCurrentRule <ProfitRule>();

            scheduledFlight.AddPassenger(TestData.SteveGeneralPassenger);
            scheduledFlight.AddPassenger(TestData.MarkGeneralPassenger);
            scheduledFlight.AddPassenger(TestData.JamesGeneralPassenger);
            scheduledFlight.AddPassenger(TestData.JaneGeneralPassenger);
            scheduledFlight.AddPassenger(TestData.AlanGeneralPassenger);
            scheduledFlight.AddPassenger(TestData.SuzyGeneralPassenger);
            scheduledFlight.AddPassenger(TestData.JohnLoyaltyPassenger);
            scheduledFlight.AddPassenger(TestData.SarahLoyaltyPassenger);
            scheduledFlight.AddPassenger(TestData.JackLoyaltyPassenger);
            scheduledFlight.AddPassenger(TestData.TrevorAirlineEmployeePassenger);

            scheduledFlight.Process();


            Assert.Equal(10, passengerService.GetCountForPassengerType <Passenger>());
            Assert.Equal(6, passengerService.GetCountForPassengerType <GeneralPassenger>());
            Assert.Equal(3, passengerService.GetCountForPassengerType <LoyaltyPassenger>());
            Assert.Equal(1, passengerService.GetCountForPassengerType <AirlineEmployeePassenger>());

            Assert.Equal(13, flightService.TotalExpectedBaggage);
            Assert.Equal(800, flightService.ProfitFromFlight);
            Assert.Equal(500, flightService.CostOfFlight);
            Assert.Equal(10, flightService.TotalLoyaltyPointsAccrued);
            Assert.Equal(100, flightService.TotalLoyaltyPointsRedeemed);
            Assert.Equal(300, flightService.ProfitSurplus);
            Assert.Equal(
                @"Flight summary for London to Paris

Total passengers: 10
    General sales: 6
    Loyalty member sales: 3
    Airline employee comps: 1

Total expected baggage: 13

Total revenue from flight: 800
Total costs from flight: 500
Flight generating profit of: 300

Total loyalty points given away: 10
Total loyalty points redeemed: 100


THIS FLIGHT MAY PROCEED",
                scheduledFlight.GetSummary());
        }
Exemplo n.º 23
0
 public static FlightDataEntitiesRT.Decisions.ConditionRelation FromAircraftService(
     AircraftService.ConditionRelation conditionRelation)
 {
     switch (conditionRelation)
     {
         case AircraftService.ConditionRelation.OR: return FlightDataEntitiesRT.Decisions.ConditionRelation.OR;
         default: return FlightDataEntitiesRT.Decisions.ConditionRelation.AND;
     }
 }
Exemplo n.º 24
0
 internal static FlightDataEntitiesRT.Decisions.DecisionRecord FromAircraftService(
     AircraftService.DecisionRecord one)
 {
     return new FlightDataEntitiesRT.Decisions.DecisionRecord()
     {
         DecisionID = one.DecisionID,
         FlightID = one.FlightID,
         EventLevel = one.EventLevel,
         DecisionDescription = one.DecisionDescription,
         DecisionName = one.DecisionName,
         StartSecond = one.StartSecond,
         EndSecond = one.EndSecond,
         HappenSecond = one.HappenSecond
     };
 }
Exemplo n.º 25
0
 public aircraftController(AircraftService aircraftService)
 {
     this._aircraftService = aircraftService;
 }
Exemplo n.º 26
0
 internal static FlightDataEntitiesRT.Flight FromAircraftService(AircraftService.Flight flight)
 {
     return new FlightDataEntitiesRT.Flight()
     {
         Aircraft = new FlightDataEntitiesRT.AircraftInstance()
         {
             AircraftModel = FromAircraftService(flight.Aircraft.AircraftModel),
             AircraftNumber = flight.Aircraft.AircraftNumber,
             LastUsed = flight.Aircraft.LastUsed
         },
         FlightName = flight.FlightName,
         FlightID = flight.FlightID,
         StartSecond = flight.StartSecond,
         EndSecond = flight.EndSecond
     };
 }
Exemplo n.º 27
0
        private async void LoadAircrafts()
        {
            var result = await AircraftService.GetAll();

            result.ForEach(x => Aircrafts.Add(x));
        }
Exemplo n.º 28
0
 public AircraftsController(AircraftService aircraftService, IConfiguration config)
 {
     _aircraftService = aircraftService;
     _config          = config;
 }
Exemplo n.º 29
0
        internal static FlightDataEntitiesRT.ExtremumPointInfo FromAircraftService(AircraftService.ExtremumPointInfo one)
        {
            if (one == null)
                return null;

            FlightDataEntitiesRT.ExtremumPointInfo info = new FlightDataEntitiesRT.ExtremumPointInfo()
            {
                MaxValue = one.MaxValue,
                MaxValueSecond = one.MaxValueSecond,
                MinValue = one.MinValue,
                MinValueSecond = one.MinValueSecond,
                ParameterID = one.ParameterID
            };

            return info;
        }
Exemplo n.º 30
0
 public ManipulateWithDbTests()
 {
     uow           = new UnitOfWork();
     service       = new AircraftService(uow);
     serviceFlight = new FlightService(uow);
 }
Exemplo n.º 31
0
        internal static FlightDataEntitiesRT.LevelTopFlightRecord FromAircraftService(AircraftService.LevelTopFlightRecord one)
        {
            FlightDataEntitiesRT.LevelTopFlightRecord rec = new FlightDataEntitiesRT.LevelTopFlightRecord()
            {
                EndSecond = one.EndSecond,
                FlightID = one.FlightID,
                ParameterID = one.ParameterID,
                StartSecond = one.StartSecond,
                ExtremumPointInfo = FromAircraftService(one.ExtremumPointInfo),
                Level2FlightRecord = FromAircraftService(one.Level2FlightRecord)
            };

            return rec;
        }
Exemplo n.º 32
0
        public void Should_Choose_Bigger_Airplane()
        {
            var passengerService = new PassengerService();
            var aircraftService  = new AircraftService();

            aircraftService
            .AddPlanes(TestData.SmallAntonovPlane,
                       TestData.BombardierPlane,
                       TestData.ATRPlane);
            var calculationService = new CalculationService();

            calculationService.AddRules(new ProfitRule(), new RelaxedRule());
            var flightService   = new FlightService(TestData.LondonToParis);
            var scheduledFlight = new ScheduledFlight(
                flightService,
                passengerService,
                aircraftService,
                calculationService,
                new SummaryFormat(passengerService, aircraftService));

            scheduledFlight.SetAircraftForRoute(122);
            scheduledFlight.SetCurrentRule <ProfitRule>();

            scheduledFlight.AddPassenger(TestData.SteveGeneralPassenger);
            scheduledFlight.AddPassenger(TestData.MarkGeneralPassenger);
            scheduledFlight.AddPassenger(TestData.JamesGeneralPassenger);
            scheduledFlight.AddPassenger(TestData.JaneGeneralPassenger);
            scheduledFlight.AddPassenger(TestData.AlanGeneralPassenger);
            scheduledFlight.AddPassenger(TestData.SuzyGeneralPassenger);
            scheduledFlight.AddPassenger(TestData.AnthonyGeneralPassenger);
            scheduledFlight.AddPassenger(TestData.MikeGeneralPassenger);
            scheduledFlight.AddPassenger(TestData.JohnLoyaltyPassenger);
            scheduledFlight.AddPassenger(TestData.SarahLoyaltyPassenger);
            scheduledFlight.AddPassenger(TestData.JackLoyaltyPassenger);
            scheduledFlight.AddPassenger(TestData.TrevorAirlineEmployeePassenger);

            scheduledFlight.Process();
            _output.WriteLine(scheduledFlight.GetSummary());

            Assert.Equal(12, passengerService.GetCountForPassengerType <Passenger>());
            Assert.Equal(8, passengerService.GetCountForPassengerType <GeneralPassenger>());
            Assert.Equal(3, passengerService.GetCountForPassengerType <LoyaltyPassenger>());
            Assert.Equal(1, passengerService.GetCountForPassengerType <AirlineEmployeePassenger>());

            Assert.Equal(15, flightService.TotalExpectedBaggage);
            Assert.Equal(1000, flightService.ProfitFromFlight);
            Assert.Equal(600, flightService.CostOfFlight);
            Assert.Equal(10, flightService.TotalLoyaltyPointsAccrued);
            Assert.Equal(100, flightService.TotalLoyaltyPointsRedeemed);
            Assert.Equal(400, flightService.ProfitSurplus);
            Assert.Equal(
                @"Flight summary for London to Paris

Total passengers: 12
    General sales: 8
    Loyalty member sales: 3
    Airline employee comps: 1

Total expected baggage: 15

Total revenue from flight: 1000
Total costs from flight: 600
Flight generating profit of: 400

Total loyalty points given away: 10
Total loyalty points redeemed: 100


FLIGHT MAY NOT PROCEED
Other more suitable aircraft are:
Bombardier Q400 could handle this flight
ATR 640 could handle this flight
",
                scheduledFlight.GetSummary());
        }
Exemplo n.º 33
0
 internal static FlightDataEntitiesRT.Charts.ChartPanel FromAircraftService(AircraftService.ChartPanel one)
 {
     if (one == null)
         return null;
     return new FlightDataEntitiesRT.Charts.ChartPanel()
     {
         PanelID = one.PanelID,
         PanelName = one.PanelName,
         ParameterIDs = one.ParameterIDs.ToArray()
     };
 }
Exemplo n.º 34
0
 internal static FlightDataEntitiesRT.AircraftModel FromAircraftService(AircraftService.AircraftModel aircraftModel)
 {
     return new FlightDataEntitiesRT.AircraftModel()
     {
         Caption = aircraftModel.Caption,
         LastUsed = aircraftModel.LastUsed,
         ModelName = aircraftModel.ModelName
     };
 }
Exemplo n.º 35
0
 internal static FlightDataEntitiesRT.Decisions.CompareOperator FromAircraftService(
     AircraftService.CompareOperator compareOperator)
 {
     switch (compareOperator)
     {
         case AircraftService.CompareOperator.GreaterOrEqual: return FlightDataEntitiesRT.Decisions.CompareOperator.GreaterOrEqual;
         case AircraftService.CompareOperator.GreaterThan: return FlightDataEntitiesRT.Decisions.CompareOperator.GreaterThan;
         case AircraftService.CompareOperator.NotEqual: return FlightDataEntitiesRT.Decisions.CompareOperator.NotEqual;
         case AircraftService.CompareOperator.SmallerOrEqual: return FlightDataEntitiesRT.Decisions.CompareOperator.SmallerOrEqual;
         case AircraftService.CompareOperator.SmallerThan: return FlightDataEntitiesRT.Decisions.CompareOperator.SmallerThan;
         default: return FlightDataEntitiesRT.Decisions.CompareOperator.Equal;
     }
 }
Exemplo n.º 36
0
        internal static FlightDataEntitiesRT.FlightParameters FromAircraftService(AircraftService.FlightParameters parameters)
        {
            if (parameters == null)
                return null;

            return new FlightDataEntitiesRT.FlightParameters()
            {
                BytesCount = parameters.BytesCount,
                Parameters = parameters.Parameters.Select<AircraftService.FlightParameter, FlightDataEntitiesRT.FlightParameter>(
                new Func<AircraftService.FlightParameter, FlightDataEntitiesRT.FlightParameter>(
                    delegate(AircraftService.FlightParameter par)
                    {
                        return new FlightDataEntitiesRT.FlightParameter()
                        {
                            Caption = par.Caption,
                            Index = par.Index,
                            SubIndex = par.SubIndex,
                            ModelName = par.ModelName,
                            ParameterDataType = par.ParameterDataType,
                            ParameterID = par.ParameterID,
                            Unit = par.Unit,
                            ByteIndexes = par.ByteIndexes == null ? new FlightDataEntitiesRT.ByteIndex[] { } :
                            (from bi in par.ByteIndexes
                             select new FlightDataEntitiesRT.ByteIndex()
                             {
                                 Index = bi.Index,
                                 SubIndexes = bi.SubIndexes == null ? new FlightDataEntitiesRT.BitIndex[] { } :
                                 (from si in bi.SubIndexes
                                  select new FlightDataEntitiesRT.BitIndex() { SubIndex = si.SubIndex }
                                 ).ToArray()
                             }).ToArray()
                        };
                    })).ToArray()
            };
        }
Exemplo n.º 37
0
 public AircraftViewModel()
 {
     _aircraftService = new AircraftService();
 }
Exemplo n.º 38
0
 public AircraftController(AircraftService aircraftService)
 {
     _aircraftService = aircraftService;
 }
Exemplo n.º 39
0
 internal static FlightDataEntitiesRT.FlightRawDataRelationPoint FromAircraftService(AircraftService.FlightRawDataRelationPoint one)
 {
     return new FlightDataEntitiesRT.FlightRawDataRelationPoint()
     {
         FlightDate = one.FlightDate,
         FlightID = one.FlightID,
         XAxisParameterID = one.XAxisParameterID,
         XAxisParameterValue = one.XAxisParameterValue,
         YAxisParameterID = one.YAxisParameterID,
         YAxisParameterValue = one.YAxisParameterValue
     };
 }