Example #1
0
        public void MoveToTest_SeekableStream(bool withCaching)
        {
            using (var ms = new MemoryStream())
            {
                var writer = new StreamWriter(ms, Encoding.Unicode);
                writer.Write(DelimitedRecordReaderTestData.SampleData1);
                writer.Flush();

                ms.Position = 0;

                using (var csv = new DelimitedRecordReader(new StreamReader(ms, Encoding.Unicode)))
                {
                    if (withCaching)
                    {
                        csv.StartCachingRecordPositions();
                    }

                    while (csv.Read() == ReadResult.Success)
                    {
                    }

                    for (int i = DelimitedRecordReaderTestData.SampleData1RecordCount - 1; i >= 0; i--)
                    {
                        Assert.AreEqual(ReadResult.Success, csv.MoveTo(i));
                        DelimitedRecordReaderTestData.CheckSampleData1(csv, false, i);
                    }
                }
            }
        }
Example #2
0
 public void ArgumentTestMoveTo()
 {
     using (DelimitedRecordReader csv = new DelimitedRecordReader(new StringReader(DelimitedRecordReaderTestData.SampleData1)))
     {
         Assert.Throws <ArgumentOutOfRangeException>(() => csv.MoveTo(-1));
     }
 }
Example #3
0
 public void MoveToTest_AfterLastRecord()
 {
     using (var csv = new DelimitedRecordReader(new StringReader(DelimitedRecordReaderTestData.SampleData1)))
     {
         Assert.AreEqual(ReadResult.Success, csv.ReadColumnHeaders());
         Assert.AreEqual(ReadResult.EndOfFile, csv.MoveTo(DelimitedRecordReaderTestData.SampleData1RecordCount));
     }
 }
Example #4
0
        public void MoveToTest_Forward(
            [Values(false, true)] bool readHeaders,
            [Range(0, DelimitedRecordReaderTestData.SampleData1RecordCount - 1)] int toRecordIndex)
        {
            using (var csv = new DelimitedRecordReader(new StringReader(DelimitedRecordReaderTestData.SampleData1)))
            {
                if (readHeaders)
                {
                    Assert.AreEqual(ReadResult.Success, csv.ReadColumnHeaders());
                }

                csv.MoveTo(toRecordIndex);
                DelimitedRecordReaderTestData.CheckSampleData1(csv, readHeaders, toRecordIndex);
            }
        }
		public void ArgumentTestMoveTo()
		{
			using (DelimitedRecordReader csv = new DelimitedRecordReader(new StringReader(DelimitedRecordReaderTestData.SampleData1)))
			{
				Assert.Throws<ArgumentOutOfRangeException>(() => csv.MoveTo(-1));
			}
		}