public void Test_Convert_model_to_lines()
        {
            FmsBuilder fmsFlightplan = Create.FmsFlightplan();

            fmsFlightplan.AddWaypoint(WaypointType.Airport, "EDDC", 0, 51.134344, 13.768);
            fmsFlightplan.AddWaypoint(WaypointType.LatLon, "+51.378_+013.115", 0, 51.378353, 13.115295);
            FmsFlightplan flightplan = fmsFlightplan.Build();

            FileInfo               outputFile     = new FileInfo("out.fms");
            IList <string>         lines          = null;
            Mock <ITextFileWriter> textWriterMock = new Mock <ITextFileWriter>();

            textWriterMock.Setup(x => x.WriteAllLines(outputFile, It.IsAny <IEnumerable <string> >())).Callback <FileInfo, IEnumerable <string> >((f, s) => lines = s.ToList());

            IFmsService service = new FmsService(textWriterMock.Object);

            service.WriteFmsFlightplanToFile(flightplan, outputFile);

            lines.Count.Should().Be(6);
            lines[0].Should().Be("I");
            lines[1].Should().Be("3 VERSION");
            lines[2].Should().Be("1");
            lines[3].Should().Be("1");
            lines[4].Should().Be("1 EDDC 0 51.134344 13.768");
            lines[5].Should().Be("28 +51.378_+013.115 0 51.378353 13.115295");
        }
Exemple #2
0
        private static void Main(string[] args)
        {
            IUnityContainer container = CreateContainer();

            IGarminFplService garminFplService = container.Resolve <IGarminFplService>();
            GarminFpl         garminFlightplan = garminFplService.GetFromXmlFile(new FileInfo(args[0]));

            IGarminFplToFmsService garminToFmsService = container.Resolve <IGarminFplToFmsService>();
            FmsFlightplan          fmsFlightplan      = garminToFmsService.CreateFmsFlightplanFromGarminFpl(garminFlightplan);

            IFmsService fmsService = container.Resolve <IFmsService>();

            fmsService.WriteFmsFlightplanToFile(fmsFlightplan, new FileInfo(args[1]));
        }
Exemple #3
0
        public void Converting_FPL_should_give_correct_FMS()
        {
            var garminFplBuilder = Create.GarminFpl();

            garminFplBuilder.AddWaypoint("AIRPORT", "EDDC", 51.134344, 51.134344);
            garminFplBuilder.AddWaypoint("VOR", "DRN", 51.015547, 13.598889);
            garminFplBuilder.AddWaypoint("INT", "DC422", 51.065489, 13.457303);
            garminFplBuilder.AddWaypoint("NDB", "FS", 51.193011, 13.850031);
            garminFplBuilder.AddWaypoint("USER WAYPOINT", "TEST1", 51.378353, 13.115295);
            garminFplBuilder.AddWaypoint("USER WAYPOINT", "TEST2", -51.378353, 13.115295);
            garminFplBuilder.AddWaypoint("USER WAYPOINT", "TEST3", -51.378353, -13.115295);
            garminFplBuilder.AddWaypoint("USER WAYPOINT", "TEST4", 51.378353, -13.115295);
            GarminFpl garminFpl = garminFplBuilder.Build();

            IGarminFplToFmsService service = new GarminFplToFmsService(new FplToFmsWaypointTypeConverter());
            FmsFlightplan          fms     = service.CreateFmsFlightplanFromGarminFpl(garminFpl);

            fms.Header.Source.Should().Be('I');
            fms.Header.VersionNumber.Should().Be(3);
            fms.Header.WaypointCount.Should().Be(7);

            PlanItem waypoint1 = fms.PlanItems[0];

            waypoint1.Typ.Should().Be(WaypointType.Airport);
            waypoint1.Id.Should().Be("EDDC");
            waypoint1.Altitude.Should().Be(0);
            waypoint1.Latitude.Should().Be(51.134344);
            waypoint1.Longitude.Should().Be(51.134344);

            PlanItem waypoint5 = fms.PlanItems[4];

            waypoint5.Typ.Should().Be(WaypointType.LatLon);
            waypoint5.Id.Should().Be("+51.378_+013.115");

            PlanItem waypoint6 = fms.PlanItems[5];

            waypoint6.Typ.Should().Be(WaypointType.LatLon);
            waypoint6.Id.Should().Be("-51.378_+013.115");

            PlanItem waypoint7 = fms.PlanItems[6];

            waypoint7.Typ.Should().Be(WaypointType.LatLon);
            waypoint7.Id.Should().Be("-51.378_-013.115");

            PlanItem waypoint8 = fms.PlanItems[7];

            waypoint8.Typ.Should().Be(WaypointType.LatLon);
            waypoint8.Id.Should().Be("+51.378_-013.115");
        }
Exemple #4
0
        public void WriteFmsFlightplanToFile(FmsFlightplan fmsFlightplan, FileInfo fileInfo)
        {
            IList <string> fmsLines = new List <string>();

            fmsLines.Add($"{fmsFlightplan.Header.Source}");
            fmsLines.Add($"{fmsFlightplan.Header.VersionNumber} VERSION");
            fmsLines.Add($"{fmsFlightplan.Header.UnknownPLaceholder}");
            fmsLines.Add($"{fmsFlightplan.Header.WaypointCount}");

            foreach (var fmsFlightplanPlanItem in fmsFlightplan.PlanItems)
            {
                fmsLines.Add(
                    $"{fmsFlightplanPlanItem.Typ.AsInt()} {fmsFlightplanPlanItem.Id} {fmsFlightplanPlanItem.Altitude.ToString(CultureInfo.InvariantCulture)} {fmsFlightplanPlanItem.Latitude.ToString(CultureInfo.InvariantCulture)} {fmsFlightplanPlanItem.Longitude.ToString(CultureInfo.InvariantCulture)}");
            }

            _textFileWriter.WriteAllLines(fileInfo, fmsLines);
        }