Exemplo n.º 1
0
        public void FluentConfigurationShouldValidateInputs()
        {
            var sut = CsvAsyncInput.ForPipeReader(null);

            Assert.Throws <ArgumentException>("delimiter", () => sut.WithDelimiter((byte)'"'));
            Assert.Throws <ArgumentException>("delimiter", () => sut.WithDelimiter((byte)'\r'));
            Assert.Throws <ArgumentException>("delimiter", () => sut.WithDelimiter((byte)'\n'));
        }
Exemplo n.º 2
0
        public async Task FluentConfigurationShouldFailAfterProcessing()
        {
            var sut = CsvAsyncInput.ForPipeReader(null);

            await sut.ProcessAsync(null).ConfigureAwait(true);

            // shouldn't be able to further configure a Stream input after processing starts...
            Assert.Throws <InvalidOperationException>(() => sut.WithDelimiter((byte)'\t'));
            Assert.Throws <InvalidOperationException>(() => sut.WithIgnoreUTF8ByteOrderMark(false));
        }
Exemplo n.º 3
0
        public async Task IgnoreUTF8BOM(string filePath, int chunkLength)
        {
            // arrange
            filePath = Path.Combine(TestCsvFilesFolderPath, filePath);

            if (new FileInfo(filePath).Length == 0)
            {
                // Pipelines.Sockets.Unofficial seems to fail here.
                return;
            }

            // act, assert
            await RunTestAsync(CreateSut, filePath, true).ConfigureAwait(true);

            CsvAsyncInputBase CreateSut()
            {
                var pipeReader = MemoryMappedPipeReader.Create(filePath, chunkLength);

                return(CsvAsyncInput.ForPipeReader(pipeReader)
                       .WithIgnoreUTF8ByteOrderMark(true));
            }
        }