public void CellReadingDateTimeDataTest(int worksheetIndex, int rowIndex, int columnIndex, DateTime expectedCellValue) { IWorksheetReader worksheetReader = new WorksheetReader(filepath); var cellCoordinates = new ExcelCellCoordinates(worksheetIndex, rowIndex, columnIndex); var cellValue = worksheetReader.GetCellDateTimeAsUTC(cellCoordinates); cellValue .Should() .Be(expectedCellValue); }
public void TryingReadingDateTimeFromCellWithAnotherDataTypeTest(int worksheetIndex, int rowIndex, int columnIndex) { IWorksheetReader worksheetReader = new WorksheetReader(filepath); var cellCoordinates = new ExcelCellCoordinates(worksheetIndex, rowIndex, columnIndex); Action getCellDateTimeAction = () => worksheetReader.GetCellDateTimeAsUTC(cellCoordinates); getCellDateTimeAction .Should() .ThrowExactly <WorksheetReaderCellValueTypeException>("trying to read cell with non-dateTime format should raise an exception") .WithMessage($"*worksheet index: {cellCoordinates.WorksheetIndex},* " + $"*row index: {cellCoordinates.RowIndex},*" + $"*column index {cellCoordinates.ColumnIndex}*" + $"*Expected type of cell's value: {typeof(DateTime)}*"); }
public IEnumerator <object[]> GetEnumerator() { var reader = new WorksheetReader(filepath); Action <ExcelCellCoordinates> getCellTextFunc = coordinates => reader.GetCellText(coordinates); Action <ExcelCellCoordinates> getCellDateTimeFunc = coordinates => reader.GetCellDateTimeAsUTC(coordinates); var getCellDataFuncs = new Action <ExcelCellCoordinates>[] { getCellTextFunc, getCellDateTimeFunc }; foreach (var func in getCellDataFuncs) { yield return(new object[] { 0, func }); yield return(new object[] { -1, func }); yield return(new object[] { -10, func }); } }