Exemple #1
0
 public void CopyCurrentRecordToTest_NoCurrentRecord()
 {
     using (var csv = new DelimitedRecordReader(new StringReader(DelimitedRecordReaderTestData.SampleData1)))
     {
         Assert.Throws <InvalidOperationException>(() => csv.CopyCurrentRecordTo(new string[DelimitedRecordReaderTestData.SampleData1RecordCount]));
     }
 }
Exemple #2
0
        public void ArgumentTestCopyCurrentRecordTo()
        {
            using (DelimitedRecordReader csv = new DelimitedRecordReader(new StringReader(DelimitedRecordReaderTestData.SampleData1)))
            {
                Assert.AreEqual(ReadResult.Success, csv.Read());
                Assert.Throws <ArgumentNullException>(() => csv.CopyCurrentRecordTo(null));
            }

            using (DelimitedRecordReader csv = new DelimitedRecordReader(new StringReader(DelimitedRecordReaderTestData.SampleData1)))
            {
                Assert.AreEqual(ReadResult.Success, csv.Read());
                Assert.Throws <ArgumentOutOfRangeException>(() => csv.CopyCurrentRecordTo(new string[1], -1));
            }

            using (DelimitedRecordReader csv = new DelimitedRecordReader(new StringReader(DelimitedRecordReaderTestData.SampleData1)))
            {
                Assert.AreEqual(ReadResult.Success, csv.Read());
                Assert.Throws <ArgumentOutOfRangeException>(() => csv.CopyCurrentRecordTo(new string[1], 1));
            }

            using (DelimitedRecordReader csv = new DelimitedRecordReader(new StringReader(DelimitedRecordReaderTestData.SampleData1)))
            {
                Assert.AreEqual(ReadResult.Success, csv.Read());
                Assert.Throws <ArgumentOutOfRangeException>(() => csv.CopyCurrentRecordTo(new string[DelimitedRecordReaderTestData.SampleData1RecordCount - 1], 0));
            }

            using (DelimitedRecordReader csv = new DelimitedRecordReader(new StringReader(DelimitedRecordReaderTestData.SampleData1)))
            {
                Assert.AreEqual(ReadResult.Success, csv.Read());
                Assert.Throws <ArgumentOutOfRangeException>(() => csv.CopyCurrentRecordTo(new string[DelimitedRecordReaderTestData.SampleData1RecordCount], 1));
            }
        }
Exemple #3
0
        public void CopyCurrentRecordToTest([Range(0, 5)] int startIndex)
        {
            using (var csv = new DelimitedRecordReader(new StringReader(DelimitedRecordReaderTestData.SampleData1)))
            {
                var record = new string[DelimitedRecordReaderTestData.SampleData1ColumnCount + startIndex];

                while (csv.Read() == ReadResult.Success)
                {
                    csv.CopyCurrentRecordTo(record, startIndex);
                    DelimitedRecordReaderTestData.CheckSampleData1(record, false, csv.CurrentRecordIndex, startIndex);
                }
            }
        }
		public void ArgumentTestCopyCurrentRecordTo()
		{
			using (DelimitedRecordReader csv = new DelimitedRecordReader(new StringReader(DelimitedRecordReaderTestData.SampleData1)))
			{
				Assert.AreEqual(ReadResult.Success, csv.Read());
				Assert.Throws<ArgumentNullException>(() => csv.CopyCurrentRecordTo(null));
			}

			using (DelimitedRecordReader csv = new DelimitedRecordReader(new StringReader(DelimitedRecordReaderTestData.SampleData1)))
			{
				Assert.AreEqual(ReadResult.Success, csv.Read());
				Assert.Throws<ArgumentOutOfRangeException>(() => csv.CopyCurrentRecordTo(new string[1], -1));
			}

			using (DelimitedRecordReader csv = new DelimitedRecordReader(new StringReader(DelimitedRecordReaderTestData.SampleData1)))
			{
				Assert.AreEqual(ReadResult.Success, csv.Read());
				Assert.Throws<ArgumentOutOfRangeException>(() => csv.CopyCurrentRecordTo(new string[1], 1));
			}

			using (DelimitedRecordReader csv = new DelimitedRecordReader(new StringReader(DelimitedRecordReaderTestData.SampleData1)))
			{
				Assert.AreEqual(ReadResult.Success, csv.Read());
				Assert.Throws<ArgumentOutOfRangeException>(() => csv.CopyCurrentRecordTo(new string[DelimitedRecordReaderTestData.SampleData1RecordCount - 1], 0));
			}

			using (DelimitedRecordReader csv = new DelimitedRecordReader(new StringReader(DelimitedRecordReaderTestData.SampleData1)))
			{
				Assert.AreEqual(ReadResult.Success, csv.Read());
				Assert.Throws<ArgumentOutOfRangeException>(() => csv.CopyCurrentRecordTo(new string[DelimitedRecordReaderTestData.SampleData1RecordCount], 1));
			}
		}