Example #1
0
        public void ReadRow_CustomMappedNullableGuid_Success()
        {
            using var importer = Helpers.GetImporter("Guids.xlsx");
            importer.Configuration.RegisterClassMap <CustomNullableGuidClassMap>();

            ExcelSheet sheet = importer.ReadSheet();

            sheet.ReadHeading();

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

            Assert.Equal(new Guid("a8a110d5fc4943c5bf46802db8f843f1"), row1.Value);

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

            Assert.Equal(new Guid("a8a110d5fc4943c5bf46802db8f843f2"), row2.Value);

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

            Assert.Equal(new Guid("a8a110d5fc4943c5bf46802db8f843f3"), row3.Value);

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

            Assert.Equal(new Guid("a8a110d5fc4943c5bf46802db8f843f4"), row4.Value);

            NullableGuidClass row5 = sheet.ReadRow <NullableGuidClass>();

            Assert.Equal(new Guid("a8a110d5fc4943c5bf46802db8f843f5"), row5.Value);

            // Empty cell value.
            NullableGuidClass row6 = sheet.ReadRow <NullableGuidClass>();

            Assert.Equal(new Guid("a8a110d5fc4943c5bf46802db8f843f6"), row6.Value);

            // Invalid cell value.
            NullableGuidClass row7 = sheet.ReadRow <NullableGuidClass>();

            Assert.Equal(new Guid("a8a110d5fc4943c5bf46802db8f843f7"), row7.Value);
        }
Example #2
0
        public void ReadRow_AutoMappedNullableGuid_Success()
        {
            using var importer = Helpers.GetImporter("Guids.xlsx");

            ExcelSheet sheet = importer.ReadSheet();

            sheet.ReadHeading();

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

            Assert.Equal(new Guid("a8a110d5fc4943c5bf46802db8f843f1"), row1.Value);

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

            Assert.Equal(new Guid("a8a110d5fc4943c5bf46802db8f843f2"), row2.Value);

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

            Assert.Equal(new Guid("a8a110d5fc4943c5bf46802db8f843f3"), row3.Value);

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

            Assert.Equal(new Guid("a8a110d5fc4943c5bf46802db8f843f4"), row4.Value);

            NullableGuidClass row5 = sheet.ReadRow <NullableGuidClass>();

            Assert.Equal(new Guid("a8a110d5fc4943c5bf46802db8f843f5"), row5.Value);

            // Empty cell value.
            NullableGuidClass row6 = sheet.ReadRow <NullableGuidClass>();

            Assert.Null(row6.Value);

            // Invalid cell value.
            Assert.Throws <ExcelMappingException>(() => sheet.ReadRow <NullableGuidClass>());
        }