Esempio n. 1
0
        public void Validate_GivenWorksheetWithMergedCells_ValidIsFalse()
        {
            //Arrange
            ExcelPackage package = new ExcelPackage();

            ExcelWorksheet workSheet = package.Workbook.Worksheets.Add("Test Worksheet");

            workSheet.Cells["A1"].Value    = "1";
            workSheet.Cells["B1"].Value    = "2";
            workSheet.Cells["C1"].Value    = "3";
            workSheet.Cells["D1"].Value    = "1";
            workSheet.Cells["E1"].Value    = "2";
            workSheet.Cells["F1"].Value    = "3";
            workSheet.Cells["B1:C1"].Merge = true;
            workSheet.Cells["D1:E1"].Merge = true;

            DatasetWorksheetValidator validator = new DatasetWorksheetValidator();

            //Act
            ValidationResult result = validator.Validate(package);

            //Assert
            result
            .IsValid
            .Should()
            .Be(false);

            result
            .Errors
            .First()
            .ErrorMessage
            .Should()
            .Be("Excel file contains merged cells");
        }
Esempio n. 2
0
        public void Validate_GivenWorksheetWithNoData_ValidIsFalse()
        {
            //Arrange
            ExcelPackage package = new ExcelPackage();

            ExcelWorksheet workSheet = package.Workbook.Worksheets.Add("Test Worksheet");

            DatasetWorksheetValidator validator = new DatasetWorksheetValidator();

            //Act
            ValidationResult result = validator.Validate(package);

            //Assert
            result
            .IsValid
            .Should()
            .Be(false);

            result
            .Errors
            .First()
            .ErrorMessage
            .Should()
            .Be("Excel file does not contain any values");
        }
Esempio n. 3
0
        public void Validate_GivenValidWorksheet_ValidIsTrue()
        {
            //Arrange
            ExcelPackage package = new ExcelPackage();

            ExcelWorksheet workSheet = package.Workbook.Worksheets.Add("Test Worksheet");

            workSheet.Cells["A1"].Value = "1";
            workSheet.Cells["B1"].Value = "2";
            workSheet.Cells["C1"].Value = "3";

            DatasetWorksheetValidator validator = new DatasetWorksheetValidator();

            //Act
            ValidationResult result = validator.Validate(package);

            //Assert
            result
            .IsValid
            .Should()
            .Be(true);
        }