public void ReadRow_AutoMappedNullableInt32_Success() { using var importer = Helpers.GetImporter("Numbers.xlsx"); ExcelSheet sheet = importer.ReadSheet(); sheet.ReadHeading(); // Valid cell value. NullableInt32Class row1 = sheet.ReadRow <NullableInt32Class>(); Assert.Equal(2, row1.Value); // Empty cell value. NullableInt32Class row2 = sheet.ReadRow <NullableInt32Class>(); Assert.Null(row2.Value); // Invalid cell value. Assert.Throws <ExcelMappingException>(() => sheet.ReadRow <Int32Value>()); }
public void ReadRow_CustomMappedNullableInt32_Success() { using var importer = Helpers.GetImporter("Numbers.xlsx"); importer.Configuration.RegisterClassMap <CustomNullableInt32ClassMap>(); ExcelSheet sheet = importer.ReadSheet(); sheet.ReadHeading(); // Valid cell value. NullableInt32Class row1 = sheet.ReadRow <NullableInt32Class>(); Assert.Equal(2, row1.Value); // Empty cell value. NullableInt32Class row2 = sheet.ReadRow <NullableInt32Class>(); Assert.Equal(-10, row2.Value); // Invalid cell value. NullableInt32Class row3 = sheet.ReadRow <NullableInt32Class>(); Assert.Equal(10, row3.Value); }