public async void An_empty_GSAK_file_outputs_an_empty_string_with_headers_only()
        {
            var expected = "\"Code\",\"Waypoint Name\",\"Latitude\",\"Longitude\"";
            var sut      = new GsakFileToStringConverter(new GsakFileLineToStringConverter());
            var actual   = await sut.Convert(GsakTestHelper.EmptyGsakFile);

            Assert.Equal(expected, actual);
        }
Esempio n. 2
0
        public async void Can_parse_BarneyGeeft_to_Gsak()
        {
            var expectedGsakLines  = 5;
            var expectedGsakString =
                "\"Code\",\"Waypoint Name\",\"Latitude\",\"Longitude\"\r\n\"GC5001N\",\"Wer andern eine Grube gräbt ..\",\"N48° 03.327\",\"E7° 52.095\"\r\n\"GC5001P\",\"Wo ist das ? (Sissy T5) -RELOADED-\",\"N48° 06.990\",\"E7° 59.760\"\r\n\"GC5001R\",\"TB = GC\",\"N48° 05.459\",\"E7° 56.868\"\r\n\"GC5002H\",\"Wo ist die Kokosnuss?\",\"N50° 44.702\",\"E6° 54.268\"\r\n\"GC500AW\",\"Challenge-Wald II - 3x 1000 (Tradi/Multi/Mysterie)\",\"N52° 17.323\",\"E10° 46.621\"";

            var sut             = new BarneyGeeftFileToGsakFileConverter(new BarneyGeeftFileLineToGsakFileLineConverter());
            var barneyGeeftFile = new BarnyGeeftFile(sut)
            {
                Lines = new [] {
                    new BarnyGeeftFileLine {
                        RawContent = "GC5001N Wer andern eine Grube gräbt .. N48° 03.327 E7° 52.095"
                    },
                    new BarnyGeeftFileLine {
                        RawContent = ""
                    },
                    new BarnyGeeftFileLine {
                        RawContent = "GC5001P Wo ist das ?  (Sissy T5) -RELOADED- N48° 06.990 E7° 59.760"
                    },
                    new BarnyGeeftFileLine {
                        RawContent = ""
                    },
                    new BarnyGeeftFileLine {
                        RawContent = "GC5001R TB = GC N48° 05.459 E7° 56.868"
                    },
                    new BarnyGeeftFileLine {
                        RawContent = ""
                    },
                    new BarnyGeeftFileLine {
                        RawContent = "GC5002H Wo ist die Kokosnuss? N50° 44.702 E6° 54.268"
                    },
                    new BarnyGeeftFileLine {
                        RawContent = ""
                    },
                    new BarnyGeeftFileLine {
                        RawContent = "GC500AW Challenge-Wald II - 3x 1000 (Tradi/Multi/Mysterie) N52° 17.323 E10° 46.621"
                    }
                }
            };

            var actualGsakFile = await barneyGeeftFile.Convert();

            var gsakFiletoStringConverter = new GsakFileToStringConverter(new GsakFileLineToStringConverter());
            var actualGstakString         = await gsakFiletoStringConverter.Convert(actualGsakFile);

            Assert.Equal(expectedGsakLines, actualGsakFile.Lines.Count());
            Assert.Equal(expectedGsakString, actualGstakString);
        }
        public async void A_valid_GSAK_file_outputs_a_header_and_each_line_on_a_seperate_line()
        {
            var gsakFileLineToStringConverter = new GsakFileLineToStringConverter();
            var expectedHeader = "\"Code\",\"Waypoint Name\",\"Latitude\",\"Longitude\"";
            var expectedBody   = String.Join(
                Environment.NewLine,
                String.Join(
                    Environment.NewLine,
                    GsakTestHelper.ValidGsakFile
                    .Lines
                    .Select(async gfl => await gsakFileLineToStringConverter.Convert(gfl))
                    .Select(gflString => gflString.Result)
                    )
                );
            var expected = $"{expectedHeader}{Environment.NewLine}{expectedBody}";
            var sut      = new GsakFileToStringConverter(new GsakFileLineToStringConverter());
            var actual   = await sut.Convert(GsakTestHelper.ValidGsakFile);

            Assert.Equal(expected, actual);
        }
Esempio n. 4
0
        public async void Can_convert_to_gsak_formatted_file()
        {
            var expected = ReadFromResource("Kf.ConverToGSAK.Api.Tests.Input.BarnyGeeft.GC5-GSAK-formatted.txt");
            var expectedNumberOfBarneyGeeftLines = 47787;
            var expectedNumberOfGsakLines        = 20193;
            var input = ReadFromResource("Kf.ConverToGSAK.Api.Tests.Input.BarnyGeeft.GC5-original.txt");

            var barneyGeeftFile = new BarnyGeeftFile(
                new BarneyGeeftFileToGsakFileConverter(new BarneyGeeftFileLineToGsakFileLineConverter()),
                input
                );

            var gsakFile = await barneyGeeftFile.Convert();

            var gsakToStringConverter = new GsakFileToStringConverter(new GsakFileLineToStringConverter());
            var actualGsakString      = await gsakToStringConverter.Convert(gsakFile);

            Assert.Equal(actualGsakString, expected);
            Assert.Equal(expectedNumberOfBarneyGeeftLines, barneyGeeftFile.Lines.Count());
            Assert.Equal(expectedNumberOfGsakLines, gsakFile.Lines.Count());
        }