public void When_source_contains_uneven_number_of_quotes_it_should_not_read_entire_source() { // Arrange const string header = "C1"; string cell = DefaultTextQualifier + "12345"; int bufferSize = header.Length + Environment.NewLine.Length + cell.Length; using DelimitedValuesReader reader = new DelimitedValuesReaderBuilder() .WithIntermediateReader(r => new ReaderThatFailsAfterReadingTooMuch(r, bufferSize)) .WithSettings(new DelimitedValuesReaderSettingsBuilder() .WithMaximumLineLength(cell.Length)) .WithHeaderLine(header) .WithoutRows() .WithDataLine(cell) .WithDataLine("A") .WithDataLine("B") .Build(); // Act // ReSharper disable once AccessToDisposedClosure Action action = () => _ = reader.SkipWhile(_ => true).ToArray(); // Assert action.Should().ThrowExactly <DelimitedValuesParseException>(); }
public void When_source_contains_uneven_number_of_quotes_it_should_fail() { // Arrange using DelimitedValuesReader reader = new DelimitedValuesReaderBuilder() .WithSingleColumnHeader() .WithoutRows() .WithDataLine(DefaultTextQualifier) .Build(); // Act // ReSharper disable once AccessToDisposedClosure Action action = () => _ = reader.SkipWhile(_ => true).ToArray(); // Assert action.Should().ThrowExactly <DelimitedValuesParseException>().WithMessage("Missing closing text qualifier."); }
public void When_source_contains_uneven_number_of_quotes_it_should_report_the_correct_starting_line_number() { // Arrange using DelimitedValuesReader reader = new DelimitedValuesReaderBuilder() .WithSingleColumnHeader() .WithoutRows() .WithDataLine(DefaultTextQualifier + "12345") .WithDataLine("A") .WithDataLine("B") .Build(); try { // Act _ = reader.SkipWhile(_ => true).ToArray(); } catch (DelimitedValuesParseException) { // Assert reader.LineNumber.Should().Be(2); } }
public void When_source_contains_uneven_number_of_quotes_it_should_report_the_correct_starting_line_number() { // Arrange DelimitedValuesReader reader = new DelimitedValuesReaderBuilder() .WithSingleColumnHeader() .WithoutRows() .WithDataLine(DefaultTextQualifier + "12345") .WithDataLine("A") .WithDataLine("B") .Build(); try { // Act // ReSharper disable once ReturnValueOfPureMethodIsNotUsed reader.SkipWhile(r => true).ToArray(); } catch (DelimitedValuesParseException) { // Assert reader.LineNumber.Should().Be(2); } }
public void When_source_contains_uneven_number_of_quotes_it_should_not_read_entire_source() { // Arrange const string header = "C1"; string cell = DefaultTextQualifier + "12345"; int bufferSize = header.Length + Environment.NewLine.Length + cell.Length; DelimitedValuesReader reader = new DelimitedValuesReaderBuilder() .WithIntermediateReader(r => new ReaderThatFailsAfterReadingTooMuch(r, bufferSize)) .WithSettings(new DelimitedValuesReaderSettingsBuilder() .WithMaximumLineLength(cell.Length)) .WithHeaderLine(header) .WithoutRows() .WithDataLine(cell) .WithDataLine("A") .WithDataLine("B") .Build(); // Act // ReSharper disable once ReturnValueOfPureMethodIsNotUsed Action action = () => reader.SkipWhile(x => true).ToArray(); // Assert action.ShouldThrow<DelimitedValuesParseException>(); }
public void When_source_contains_uneven_number_of_quotes_it_should_fail() { // Arrange DelimitedValuesReader reader = new DelimitedValuesReaderBuilder() .WithSingleColumnHeader() .WithoutRows() .WithDataLine(DefaultTextQualifier) .Build(); // Act // ReSharper disable once ReturnValueOfPureMethodIsNotUsed Action action = () => reader.SkipWhile(x => true).ToArray(); // Assert action.ShouldThrow<DelimitedValuesParseException>().WithMessage("Missing closing text qualifier."); }