Example #1
0
        public void ReadRow_AutoMappedNullableFloat_Success()
        {
            using (var importer = Helpers.GetImporter("Doubles.xlsx"))
            {
                ExcelSheet sheet = importer.ReadSheet();
                sheet.ReadHeading();

                // Valid cell value.
                NullableFloatValue row1 = sheet.ReadRow <NullableFloatValue>();
                Assert.Equal(2.2345f, row1.Value);

                // Empty cell value.
                NullableFloatValue row2 = sheet.ReadRow <NullableFloatValue>();
                Assert.Null(row2.Value);

                // Invalid cell value.
                Assert.Throws <ExcelMappingException>(() => sheet.ReadRow <NullableFloatValue>());
            }
        }
Example #2
0
        public void ReadRow_CustomMappedNullableFloat_Success()
        {
            using (var importer = Helpers.GetImporter("Doubles.xlsx"))
            {
                importer.Configuration.RegisterClassMap <NullableFloatValueFallbackMap>();

                ExcelSheet sheet = importer.ReadSheet();
                sheet.ReadHeading();

                // Valid cell value.
                NullableFloatValue row1 = sheet.ReadRow <NullableFloatValue>();
                Assert.Equal(2.2345f, row1.Value);

                // Empty cell value.
                NullableFloatValue row2 = sheet.ReadRow <NullableFloatValue>();
                Assert.Equal(-10, row2.Value);

                // Invalid cell value.
                NullableFloatValue row3 = sheet.ReadRow <NullableFloatValue>();
                Assert.Equal(10, row3.Value);
            }
        }