示例#1
0
        public void ParseEmptyFileWithCarriageReturnNewline()
        {
            var writer = new StringWriter();

            string[][] values = CsvWriterExtensions.ParseCsvFile("\r\n");
            values.Should().BeEmpty();
        }
示例#2
0
 public void ParseEmptyValue()
 {
     string[][] values = CsvWriterExtensions.ParseCsvFile("\"\"\r\n");
     values.Should().ContainSingle();
     values[0].Should().ContainSingle();
     values[0][0].Should().Be("");
 }
示例#3
0
 public void ParseMultipleSingleFieldRecordsNewline()
 {
     string[][] values = CsvWriterExtensions.ParseCsvFile("a\nb\n");
     values.Should().HaveCount(2);
     values[0].Should().Equal(new[] { "a" });
     values[1].Should().Equal(new[] { "b" });
 }
示例#4
0
 public void ParseQuotedField()
 {
     string[][] values =
         CsvWriterExtensions.ParseCsvFile("a,\"a \"\"quoted\"\" string \r\n newlines\",first\r\n");
     values.Should().ContainSingle();
     values[0].Should().Equal(new[] { "a", "a \"quoted\" string \r\n newlines", "first" });
 }
        public async Task BasicSend(object inputValue, KustoDataType dataType, string representation)
        {
            string saved  = null;
            var    ingest = new Mock <IKustoIngestClient>();

            ingest.Setup(i => i.IngestFromStreamAsync(
                             It.IsAny <Stream>(),
                             It.IsAny <KustoIngestionProperties>(),
                             It.IsAny <StreamSourceOptions>()))
            .Callback((Stream s, KustoIngestionProperties p, StreamSourceOptions o) =>
            {
                saved = new StreamReader(s).ReadToEnd();
            })
            .Returns(Task.FromResult(Mock.Of <IKustoIngestionResult>()));

            await KustoHelpers.WriteDataToKustoInMemoryAsync(ingest.Object,
                                                             "TEST-DATABASE",
                                                             "TEST-TABLE",
                                                             new NUnitLogger(),
                                                             new[] { inputValue },
                                                             v => new[]
            {
                new KustoValue("columnName", v, dataType),
            }
                                                             );

            string[][] parsed = CsvWriterExtensions.ParseCsvFile(saved);
            parsed.Should().ContainSingle();
            parsed[0].Should().ContainSingle();
            parsed[0][0].Should().Be(representation);
        }
示例#6
0
        public void ParseSimpleSingleValue()
        {
            var writer = new StringWriter();

            string[][] values = CsvWriterExtensions.ParseCsvFile("a\r\n");
            values.Should().ContainSingle();
            values[0].Should().ContainSingle();
            values[0][0].Should().Be("a");
        }
示例#7
0
 public void ParseMultipleFields()
 {
     string[][] values = CsvWriterExtensions.ParseCsvFile("a,1,,first\r\n");
     values.Should().ContainSingle();
     values[0].Should().Equal(new[] { "a", "1", "", "first" });
 }
示例#8
0
 public void ParseEmptyFileWithNewline()
 {
     string[][] values = CsvWriterExtensions.ParseCsvFile("\n");
     values.Should().BeEmpty();
 }