perf: optimize ExcelIO tests with fixture-based consolidation
- Add WorkbookFixtureBase and 4 concrete fixtures for shared workbooks - Add ExcelTestHelpers with shared utility methods - Create Integration/ folder with 7 fixture-based test classes: - MinimalSearchTests (5 tests) - SearchResultsSheetTests (5 tests) - MisInfoSheetTests (11 tests) - InvestigationSheetTests (7 tests) - ProtectionAndStyleTests (7 tests) - LegacyFormatTests (5 tests) - LargeDataSetTests (1 test) - Delete redundant ExcelExportIntegrationTests.cs (26 tests) - Delete redundant LegacyComparisonTests.cs (16 tests) - Reduce workbook generations from ~42 to 4 fixtures - Test runtime reduced from ~18 min to ~4 min (76% improvement) - All 122 ExcelIO tests pass
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
using ClosedXML.Excel;
|
||||
using JdeScoping.ExcelIO.Tests.Fixtures;
|
||||
using Shouldly;
|
||||
using Xunit;
|
||||
|
||||
namespace JdeScoping.ExcelIO.Tests.Integration;
|
||||
|
||||
public class ProtectionAndStyleTests : IClassFixture<WithMisDataFixture>
|
||||
{
|
||||
private readonly XLWorkbook _workbook;
|
||||
|
||||
public ProtectionAndStyleTests(WithMisDataFixture fixture)
|
||||
{
|
||||
_workbook = fixture.Workbook;
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AllDataSheets_AreProtected()
|
||||
{
|
||||
_workbook.Worksheet("Search Results").Protection.IsProtected.ShouldBeTrue();
|
||||
_workbook.Worksheet("MIS Info").Protection.IsProtected.ShouldBeTrue();
|
||||
_workbook.Worksheet("Investigation").Protection.IsProtected.ShouldBeTrue();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Protection_AllowsFiltering()
|
||||
{
|
||||
var sheet = _workbook.Worksheet("Search Results");
|
||||
sheet.Protection.AllowedElements.HasFlag(XLSheetProtectionElements.AutoFilter).ShouldBeTrue();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Protection_AllowsSorting()
|
||||
{
|
||||
var sheet = _workbook.Worksheet("Search Results");
|
||||
sheet.Protection.AllowedElements.HasFlag(XLSheetProtectionElements.Sort).ShouldBeTrue();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Protection_AllowsFormatting()
|
||||
{
|
||||
var sheet = _workbook.Worksheet("Search Results");
|
||||
sheet.Protection.AllowedElements.HasFlag(XLSheetProtectionElements.FormatCells).ShouldBeTrue();
|
||||
sheet.Protection.AllowedElements.HasFlag(XLSheetProtectionElements.FormatColumns).ShouldBeTrue();
|
||||
sheet.Protection.AllowedElements.HasFlag(XLSheetProtectionElements.FormatRows).ShouldBeTrue();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AllTables_UseLight18Style()
|
||||
{
|
||||
_workbook.Worksheet("Search Results").Tables.First().Theme.ShouldBe(XLTableTheme.TableStyleLight18);
|
||||
_workbook.Worksheet("MIS Info").Tables.First().Theme.ShouldBe(XLTableTheme.TableStyleLight18);
|
||||
_workbook.Worksheet("Investigation").Tables.First().Theme.ShouldBe(XLTableTheme.TableStyleLight18);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void HeaderCells_HaveCorrectFormatting()
|
||||
{
|
||||
var sheet = _workbook.Worksheet("Search Criteria");
|
||||
var headerCell = sheet.Cell(1, 1);
|
||||
headerCell.Style.Font.Bold.ShouldBeTrue();
|
||||
headerCell.Style.Fill.BackgroundColor.ShouldBe(XLColor.Gainsboro);
|
||||
headerCell.Style.Alignment.Horizontal.ShouldBe(XLAlignmentHorizontalValues.Center);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CriteriaTimestamp_MatchesLegacyFormat()
|
||||
{
|
||||
var sheet = _workbook.Worksheet("Search Criteria");
|
||||
var timestamp = sheet.Cell(4, 2).Value.GetText();
|
||||
timestamp.ShouldContain("Jan 15, 2024");
|
||||
timestamp.ShouldContain("02:30:45");
|
||||
timestamp.ShouldContain("EST");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user