예제 #1
0
 public void WhenFieldIsNumber_ReturnInvariantLocaleNumber()
 {
     using (var dataReader = new MockExcelDataReader("Sheet1:2.5"))
         using (var reader = new ExcelRowReader(dataReader, new Regex[0]))
         {
             Assert.Collection(reader, x => Assert.Equal("2.5", x.Fields[0]));
         }
 }
예제 #2
0
 public void GivenSingleRowSingleSheetInput_WhenSheetDoesntMatch_ThenReturnsEmptyEnumerable()
 {
     using (var dataReader = new MockExcelDataReader("Sheet1:Hello,World"))
         using (var reader = new ExcelRowReader(dataReader, new Regex[] { new Regex("NotSheet1") }))
         {
             Assert.Empty(reader);
         }
 }
예제 #3
0
 public void GivenSingleRowSingleSheetInput_WhenFieldIsDate_ReturnIsoDate()
 {
     using (var dataReader = new MockExcelDataReader("Sheet1:2012-12-31"))
         using (var reader = new ExcelRowReader(dataReader, new Regex[0]))
         {
             Assert.Collection(reader, x => Assert.Equal("2012-12-31", x.Fields[0]));
         }
 }
예제 #4
0
 public void GivenSingleRowSingleSheetInput_ThenSheetReturnsSheetName()
 {
     using (var dataReader = new MockExcelDataReader("Sheet1:Hello,World"))
         using (var reader = new ExcelRowReader(dataReader, new Regex[0]))
         {
             Assert.Collection(reader, x => Assert.Equal("Sheet1", x.Sheet));
         }
 }
예제 #5
0
 public void WhenFieldIsUnsupportedDataType_ThrowUnsupportedDataTypeException()
 {
     using (var dataReader = new MockExcelDataReader("Sheet1:[object]"))
         using (var reader = new ExcelRowReader(dataReader, new Regex[0]))
         {
             Assert.Throws <UnsupportedDataTypeException>(() => reader.First());
         }
 }
예제 #6
0
 public void GivenTwoRowsWithDifferentSheets_ThenSheetReturnsSheetName()
 {
     using (var dataReader = new MockExcelDataReader("Sheet1:Hello,World\nSheet2:Foo"))
         using (var reader = new ExcelRowReader(dataReader, new Regex[0]))
         {
             Assert.Collection(reader, x => Assert.Equal("Sheet1", x.Sheet)
                               , x => Assert.Equal("Sheet2", x.Sheet));
         }
 }
예제 #7
0
 public void GivenSingleRowSingleSheetInput_WhenSheetMatchesExpression_ThenReturnSingleIRow()
 {
     using (var dataReader = new MockExcelDataReader("Sheet1:Hello,World"))
         using (var reader = new ExcelRowReader(dataReader, new Regex[] { new Regex("Sheet1") }))
         {
             Assert.Collection(reader, x => Assert.Collection(x.Fields, f => Assert.Equal("Hello", f),
                                                              f => Assert.Equal("World", f)));
         }
 }
예제 #8
0
 public void GivenSingleSheetSingleRows_ThenGetSourceFieldReturnsCorrectExcelReference()
 {
     using (var dataReader = new MockExcelDataReader("Sheet1:Hello,World"))
         using (var reader = new ExcelRowReader(dataReader, new Regex[0]))
         {
             Assert.Collection(reader, x => Assert.Collection(x.Fields, f => Assert.Equal("Sheet1!A1", x.GetSourceField(0)),
                                                              f => Assert.Equal("Sheet1!B1", x.GetSourceField(1))));
         }
 }
예제 #9
0
 public void WhenReadingMultipleSheets_ThenRowNumberResetsToOneAtTheStartOfEachSheet()
 {
     using (var dataReader = new MockExcelDataReader("Sheet1:Hello\nSheet2:World"))
         using (var reader = new ExcelRowReader(dataReader, new Regex[0]))
         {
             Assert.Collection(reader, x => Assert.Equal("Sheet1!1", x.GetSourceRow()),
                               x => Assert.Equal("Sheet2!1", x.GetSourceRow()));
         }
 }
예제 #10
0
 public void WhenReadingSingleSheetMultipleRows_ThenRowNumberIncreasesMonotonically()
 {
     using (var dataReader = new MockExcelDataReader("Sheet1:Hello\nSheet1:World"))
         using (var reader = new ExcelRowReader(dataReader, new Regex[0]))
         {
             Assert.Collection(reader, x => Assert.Equal("Sheet1!1", x.GetSourceRow()),
                               x => Assert.Equal("Sheet1!2", x.GetSourceRow()));
         }
 }
예제 #11
0
 public void WhenFieldIsBoolean_ReturnTrueOrFalse()
 {
     using (var dataReader = new MockExcelDataReader("Sheet1:TRUE,FALSE"))
         using (var reader = new ExcelRowReader(dataReader, new Regex[0]))
         {
             Assert.Collection(reader, x => Assert.Collection(x.Fields,
                                                              f => Assert.Equal("True", f),
                                                              f => Assert.Equal("False", f)));
         }
 }