public void NoRowsTest() { var book = new ExcelBook("excel-sharp.xlsx"); var sheet = book.GetSheet("Fetch"); var models = sheet.Fetch <DateFetchModel>("A2", x => new { x.Name, x.Date, x.StringDate, x.NumberDate, x.FormulaDate }); Assert.Empty(models); }
public void NullableDateFetchTest() { var book = new ExcelBook("excel-sharp.xlsx"); var sheet = book.GetSheet("Fetch"); var models = sheet.Fetch <NullableDateFetchModel>("A11", x => new { x.Name, x.Date, x.StringDate, x.NumberDate, x.FormulaDate }); var date = new DateTime(2000, 1, 1); var valueModel = models[0]; Assert.Equal(date, valueModel.Date); Assert.Equal(date, valueModel.StringDate); Assert.Equal(date, valueModel.NumberDate); Assert.Equal(date, valueModel.FormulaDate); var blankModel = models[1]; Assert.Null(blankModel.Date); Assert.Null(blankModel.StringDate); Assert.Null(blankModel.NumberDate); Assert.Null(blankModel.FormulaDate); }
public void NumberFetchTest() { var book = new ExcelBook("excel-sharp.xlsx"); var sheet = book.GetSheet("Fetch"); var models = sheet.Fetch <NumberFetchModel>("A16", x => new { x.Name, x.Byte, x.Char, x.Int16, x.UInt16, x.Int32, x.UInt32, x.Int64, x.UInt64, x.Single, x.Double, x.Decimal, x.Formula }); var valueModel = models[0]; Assert.Equal(100, valueModel.Byte); Assert.Equal(100, valueModel.Char); Assert.Equal(100, valueModel.Int16); Assert.Equal(100, valueModel.UInt16); Assert.Equal(100, valueModel.Int32); Assert.Equal(100u, valueModel.UInt32); Assert.Equal(100, valueModel.Int64); Assert.Equal(100uL, valueModel.UInt64); Assert.Equal(100, valueModel.Single); Assert.Equal(100, valueModel.Double); Assert.Equal(100m, valueModel.Decimal); Assert.Equal(100, valueModel.Formula); var blankModel = models[1]; Assert.Equal(0, blankModel.Byte); Assert.Equal(0, blankModel.Char); Assert.Equal(0, blankModel.Int16); Assert.Equal(0, blankModel.UInt16); Assert.Equal(0, blankModel.Int32); Assert.Equal(0u, blankModel.UInt32); Assert.Equal(0, blankModel.Int64); Assert.Equal(0uL, blankModel.UInt64); Assert.Equal(0, blankModel.Single); Assert.Equal(0, blankModel.Double); Assert.Equal(0, blankModel.Decimal); Assert.Equal(0, blankModel.Formula); }