Exemple #1
0
        public void ReadRow_AutoMappedNullableBool_Success()
        {
            using (var importer = Helpers.GetImporter("Bools.xlsx"))
            {
                ExcelSheet sheet = importer.ReadSheet();
                sheet.ReadHeading();

                // Valid cell value.
                NullableBoolValue row1 = sheet.ReadRow <NullableBoolValue>();
                Assert.True(row1.Value);

                NullableBoolValue row2 = sheet.ReadRow <NullableBoolValue>();
                Assert.True(row2.Value);

                NullableBoolValue row3 = sheet.ReadRow <NullableBoolValue>();
                Assert.False(row3.Value);

                NullableBoolValue row4 = sheet.ReadRow <NullableBoolValue>();
                Assert.False(row4.Value);

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

                // Invalid cell value.
                Assert.Throws <ExcelMappingException>(() => sheet.ReadRow <NullableBoolValue>());
            }
        }
Exemple #2
0
        public void ReadRow_CustomMappedNullableBool_Success()
        {
            using (var importer = Helpers.GetImporter("Bools.xlsx"))
            {
                importer.Configuration.RegisterClassMap <NullableBoolValueFallbackMap>();

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

                // Valid cell value.
                NullableBoolValue row1 = sheet.ReadRow <NullableBoolValue>();
                Assert.True(row1.Value);

                NullableBoolValue row2 = sheet.ReadRow <NullableBoolValue>();
                Assert.True(row2.Value);

                NullableBoolValue row3 = sheet.ReadRow <NullableBoolValue>();
                Assert.False(row3.Value);

                NullableBoolValue row4 = sheet.ReadRow <NullableBoolValue>();
                Assert.False(row4.Value);

                // Empty cell value.
                NullableBoolValue row5 = sheet.ReadRow <NullableBoolValue>();
                Assert.True(row5.Value);

                // Invalid cell value.
                NullableBoolValue row6 = sheet.ReadRow <NullableBoolValue>();
                Assert.True(row6.Value);
            }
        }
        public void ReadRow_DefaultMappedNullableBool_Success()
        {
            using var importer = Helpers.GetImporter("Bools.xlsx");
            importer.Configuration.RegisterClassMap <DefaultNullableBoolMap>();

            ExcelSheet sheet = importer.ReadSheet();

            sheet.ReadHeading();

            // Valid cell value.
            NullableBoolValue row1 = sheet.ReadRow <NullableBoolValue>();

            Assert.True(row1.Value);

            NullableBoolValue row2 = sheet.ReadRow <NullableBoolValue>();

            Assert.True(row2.Value);

            NullableBoolValue row3 = sheet.ReadRow <NullableBoolValue>();

            Assert.False(row3.Value);

            NullableBoolValue row4 = sheet.ReadRow <NullableBoolValue>();

            Assert.False(row4.Value);

            // Empty cell value.
            NullableBoolValue row5 = sheet.ReadRow <NullableBoolValue>();

            Assert.Null(row5.Value);

            // Invalid cell value.
            Assert.Throws <ExcelMappingException>(() => sheet.ReadRow <NullableBoolValue>());
        }
Exemple #4
0
        internal void WriteInheritedOptionInfo()
        {
            Console.WriteLine("Int:{0},BoolValue:{1},EnumValue:{2},NullableInt:{3},NullableBoolValue:{4},NullableEnum:{5}",
                              Int,
                              BoolValue,
                              EnumValue,
                              NullableInt.HasValue ? NullableInt.ToString() : "null",
                              NullableBoolValue.HasValue ? NullableBoolValue.ToString() : "null",
                              NullableEnum.HasValue ? NullableEnum.ToString() : "null",
                              StringValue);

            Console.WriteLine($"StringValue:{StringValue}");

            Console.WriteLine($"MutiIntValues{MutiIntValues.Length}:");
            for (int i = 0; i < MutiIntValues.Length; i++)
            {
                Console.WriteLine($"\t[{i}]:{MutiIntValues[i]}");
            }
        }