예제 #1
0
        public void AskFlightMereTime()
        {
            FlightCalculator calculator = new FlightCalculator();

            // Positions at the flight plan.
            DateTime        launchTime = new DateTime(2020, 5, 24, 20, 4, 30);
            InitialLocation launch     = new InitialLocation(100, 100, launchTime);
            FlightStatus    middle     = new FlightStatus(120, 200, 300);
            FlightStatus    end        = new FlightStatus(140, 250, 200);

            // Generate the flight plan based on those positions.
            FlightPlan flightPlan = new FlightPlan(256, "TestCompany", launch, new FlightStatus[2] {
                middle, end
            });


            DateTime mereTime = launchTime.AddSeconds(150);

            // The test asks for a point at mere time.
            var res = calculator.CreateFlightFromPlan(flightPlan, mereTime, false);

            // Check that expected values are retrieved.
            Assert.AreEqual(110, res.Longitude);
            Assert.AreEqual(150, res.Latitude);
        }
        private Double CalculateFlightDistanceCommandExecute(Object parameter)
        {
            Double distance = FlightCalculator.FlightDistance(
                DepartureAirport.Latitude.Value,
                DepartureAirport.Longitude.Value,
                ArrivalAirport.Latitude.Value,
                ArrivalAirport.Longitude.Value);

            return(distance);
        }
예제 #3
0
        public override FlightInformation Fly(Airport destinationAirport)
        {
            var flightInformation = new FlightInformation();

            flightInformation.DistanceInKilometers = FlightCalculator.CalculateDistance(CurrentAirport.Longitude, CurrentAirport.Latitude,
                                                                                        destinationAirport.Longitude, destinationAirport.Latitude);

            flightInformation.EstimatedTimeInHours = FlightCalculator.CalculateEstimatedTime(flightInformation.DistanceInKilometers, AirspeedInKilometersPerHour);

            flightInformation.FuelUseInLitres = FlightCalculator.CalculateFuelUse(flightInformation.DistanceInKilometers, FuelConsumptionInKilometerPerLitre);

            return(flightInformation);
        }
예제 #4
0
        public void GetAirSpeed_NotNailed_NorwegianBlueParrot_should_return_expectedSpeed(int voltage, int expectedSpeed)
        {
            // Arrange
            var sut = new BirdProperties()
            {
                Type = "NorwegianBlueParrot", Voltage = voltage, IsNailed = false
            };

            // Act
            var outcome = new FlightCalculator().GetAirSpeed(sut);

            // Assert
            outcome.Should().Be(expectedSpeed);
        }
예제 #5
0
        public void GetAirSpeed_AfricanSwallow_should_return_expectedSpeed(int numberOfCoconuts, int expectedSpeed)
        {
            // Arrange
            var sut = new BirdProperties()
            {
                Type = "AfricanSwallow", NumberOfCoconuts = numberOfCoconuts
            };

            // Act
            var outcome = new FlightCalculator().GetAirSpeed(sut);

            // Assert
            outcome.Should().Be(expectedSpeed);
        }
예제 #6
0
        public void GetAirSpeed_EuropeanSwallow_should_return_35()
        {
            // Arrange
            const int expected = 35;
            var       sut      = new BirdProperties()
            {
                Type = "EuropeanSwallow"
            };

            // Act
            var outcome = new FlightCalculator().GetAirSpeed(sut);

            // Assert
            outcome.Should().Be(expected);
        }
예제 #7
0
        public void GetAirSpeed_Unknown_type_should_return_0(string type)
        {
            // Arrange
            const int expected = 0;
            var       sut      = new BirdProperties()
            {
                Type = type
            };

            // Act
            var outcome = new FlightCalculator().GetAirSpeed(sut);

            // Assert
            outcome.Should().Be(expected);
        }
예제 #8
0
        public void GetAirSpeed_Nailed_NorwegianBlueParrot_should_return_0()
        {
            // Arrange
            const int expected = 0;
            var       sut      = new BirdProperties()
            {
                Type = "NorwegianBlueParrot", IsNailed = true
            };

            // Act
            var outcome = new FlightCalculator().GetAirSpeed(sut);

            // Assert
            outcome.Should().Be(expected);
        }
예제 #9
0
        public void AskFlightAfterLand()
        {
            FlightCalculator calculator = new FlightCalculator();

            // Positions at the flight plan.
            DateTime        launchTime = new DateTime(2020, 5, 24, 20, 4, 30);
            InitialLocation launch     = new InitialLocation(100, 100, launchTime);
            FlightStatus    middle     = new FlightStatus(100, 200, 300);
            FlightStatus    end        = new FlightStatus(100, 250, 200);

            // Generate the flight plan based on those positions.
            FlightPlan flightPlan = new FlightPlan(256, "TestCompany", launch, new FlightStatus[2] {
                middle, end
            });

            // The test asks for a point after land time.
            DateTime afterLand = new DateTime(2021, 6, 27, 22, 41, 35);

            // The expected value is null.
            Assert.IsNull(calculator.CreateFlightFromPlan(flightPlan, afterLand, false));
        }
예제 #10
0
 public FlightModule(IFlightRepository flightRepo)
 {
     _flightRepo = flightRepo;
     _calculator = new FlightCalculator();
 }
예제 #11
0
 private void RefreshAvailableDistanceIndicator()
 {
     if (_baseViewModel.PlaneIndicator != null)
     {
         doubleToHour displayHourConverter     = new doubleToHour();
         Int32        departureAndArrivalDelay = 2;
         //Generate 2h to 48h with 15m steps
         DistanceAvailable = Enumerable.Range(0, (48 - departureAndArrivalDelay) * 4 + 1)
                             .Select(i => i / 4.0 + departureAndArrivalDelay)
                             .ToDictionary(hour => Convert.ToInt32(Math.Ceiling(FlightCalculator.DistanceFromFlightTime(hour, _baseViewModel.PlaneIndicator))),
                                           hour => (String)displayHourConverter.Convert(hour, typeof(String), null, CultureInfo.InvariantCulture));
     }
     else
     {
         DistanceAvailable = new Dictionary <Int32, String>();
     }
 }
        private Double CalculateFlightTimeCommandExecute(Object parameter)
        {
            Double time = FlightCalculator.FlightTimeFromDistance(FlightDistance, PlaneIndicator);

            return(time);
        }
예제 #13
0
 public void setUp()
 {
     //arrange
     uut = new FlightCalculator();
 }