Migrate ExcelIO from ClosedXML to NPOI

This commit is contained in:
Joseph Doherty
2026-02-06 17:27:09 -05:00
parent 070d915b12
commit dd18a05408
26 changed files with 3034 additions and 2805 deletions
@@ -1,86 +1,87 @@
using ClosedXML.Excel;
using JdeScoping.ExcelIO.Tests.Fixtures;
using Shouldly;
using Xunit;
namespace JdeScoping.ExcelIO.Tests.Integration;
public class InvestigationSheetTests : IClassFixture<WithMisDataFixture>
{
private readonly XLWorkbook _workbook;
private readonly IXLWorksheet _sheet;
private readonly List<string> _headers;
public InvestigationSheetTests(WithMisDataFixture fixture)
{
_workbook = fixture.Workbook;
_sheet = _workbook.Worksheet("Investigation");
_headers = ExcelTestHelpers.GetHeadersFromSheet(_sheet);
}
[Fact]
public void InvestigationSheet_Exists()
{
_workbook.Worksheets.TryGetWorksheet("Investigation", out _).ShouldBeTrue();
}
[Fact]
public void ColumnCount_Is12()
{
_headers.Count.ShouldBe(12);
}
[Fact]
public void ColumnHeaders_MatchExpected()
{
_headers.ShouldContain("Work Center Code");
_headers.ShouldContain("Work Order Number");
_headers.ShouldContain("Work Order Start Date");
_headers.ShouldContain("Job Step Number");
_headers.ShouldContain("Function Operation Description");
_headers.ShouldContain("Job Step End Date");
_headers.ShouldContain("Function Code");
_headers.ShouldContain("Was Job Step Added?");
_headers.ShouldContain("Matched Job Step Number");
_headers.ShouldContain("Item Number");
_headers.ShouldContain("Item Description");
_headers.ShouldContain("Routing Type");
}
[Fact]
public void ColumnOrder_MatchesSpec()
{
_headers[0].ShouldBe("Work Center Code");
_headers[1].ShouldBe("Work Order Number");
_headers[2].ShouldBe("Work Order Start Date");
_headers[3].ShouldBe("Job Step Number");
_headers[4].ShouldBe("Function Operation Description");
_headers[5].ShouldBe("Job Step End Date");
_headers[6].ShouldBe("Function Code");
_headers[7].ShouldBe("Was Job Step Added?");
_headers[8].ShouldBe("Matched Job Step Number");
_headers[9].ShouldBe("Item Number");
_headers[10].ShouldBe("Item Description");
_headers[11].ShouldBe("Routing Type");
}
[Fact]
public void TableStyle_IsLight18()
{
var table = _sheet.Tables.First();
table.Theme.ShouldBe(XLTableTheme.TableStyleLight18);
}
[Fact]
public void Protection_IsEnabled()
{
_sheet.Protection.IsProtected.ShouldBeTrue();
}
[Fact]
public void DataRow_ContainsExpectedValues()
{
_sheet.Cell(2, 2).Value.GetNumber().ShouldBe(12345);
_sheet.Cell(2, 10).Value.GetText().ShouldBe("ITEM-001");
}
}
using JdeScoping.ExcelIO.Tests.Fixtures;
using NPOI.SS.UserModel;
using NPOI.XSSF.UserModel;
using Shouldly;
using Xunit;
namespace JdeScoping.ExcelIO.Tests.Integration;
public class InvestigationSheetTests : IClassFixture<WithMisDataFixture>
{
private readonly XSSFWorkbook _workbook;
private readonly ISheet _sheet;
private readonly List<string> _headers;
public InvestigationSheetTests(WithMisDataFixture fixture)
{
_workbook = fixture.Workbook;
_sheet = _workbook.GetSheet("Investigation")!;
_headers = ExcelTestHelpers.GetHeadersFromSheet(_sheet);
}
[Fact]
public void InvestigationSheet_Exists()
{
_workbook.GetSheet("Investigation").ShouldNotBeNull();
}
[Fact]
public void ColumnCount_Is12()
{
_headers.Count.ShouldBe(12);
}
[Fact]
public void ColumnHeaders_MatchExpected()
{
_headers.ShouldContain("Work Center Code");
_headers.ShouldContain("Work Order Number");
_headers.ShouldContain("Work Order Start Date");
_headers.ShouldContain("Job Step Number");
_headers.ShouldContain("Function Operation Description");
_headers.ShouldContain("Job Step End Date");
_headers.ShouldContain("Function Code");
_headers.ShouldContain("Was Job Step Added?");
_headers.ShouldContain("Matched Job Step Number");
_headers.ShouldContain("Item Number");
_headers.ShouldContain("Item Description");
_headers.ShouldContain("Routing Type");
}
[Fact]
public void ColumnOrder_MatchesSpec()
{
_headers[0].ShouldBe("Work Center Code");
_headers[1].ShouldBe("Work Order Number");
_headers[2].ShouldBe("Work Order Start Date");
_headers[3].ShouldBe("Job Step Number");
_headers[4].ShouldBe("Function Operation Description");
_headers[5].ShouldBe("Job Step End Date");
_headers[6].ShouldBe("Function Code");
_headers[7].ShouldBe("Was Job Step Added?");
_headers[8].ShouldBe("Matched Job Step Number");
_headers[9].ShouldBe("Item Number");
_headers[10].ShouldBe("Item Description");
_headers[11].ShouldBe("Routing Type");
}
[Fact]
public void TableStyle_IsLight18()
{
var table = ExcelTestHelpers.GetFirstTable(_sheet);
table.StyleName.ShouldBe("TableStyleLight18");
}
[Fact]
public void Protection_IsEnabled()
{
((XSSFSheet)_sheet).IsSheetLocked.ShouldBeTrue();
}
[Fact]
public void DataRow_ContainsExpectedValues()
{
ExcelTestHelpers.GetCellNumber(_sheet, 2, 2).ShouldBe(12345);
ExcelTestHelpers.GetCellText(_sheet, 2, 10).ShouldBe("ITEM-001");
}
}
@@ -1,24 +1,24 @@
using ClosedXML.Excel;
using JdeScoping.ExcelIO.Tests.Fixtures;
using Shouldly;
using Xunit;
namespace JdeScoping.ExcelIO.Tests.Integration;
public class LargeDataSetTests : IClassFixture<LargeDataSetFixture>
{
private readonly XLWorkbook _workbook;
public LargeDataSetTests(LargeDataSetFixture fixture)
{
_workbook = fixture.Workbook;
}
[Fact]
public void TableRowCount_Is1001()
{
var sheet = _workbook.Worksheet("Search Results");
var table = sheet.Tables.First();
table.RowCount().ShouldBe(1001); // 1 header + 1000 data rows
}
}
using JdeScoping.ExcelIO.Tests.Fixtures;
using NPOI.XSSF.UserModel;
using Shouldly;
using Xunit;
namespace JdeScoping.ExcelIO.Tests.Integration;
public class LargeDataSetTests : IClassFixture<LargeDataSetFixture>
{
private readonly XSSFWorkbook _workbook;
public LargeDataSetTests(LargeDataSetFixture fixture)
{
_workbook = fixture.Workbook;
}
[Fact]
public void TableRowCount_Is1001()
{
var sheet = _workbook.GetSheet("Search Results")!;
var table = ExcelTestHelpers.GetFirstTable(sheet);
ExcelTestHelpers.GetTableRowCount(table).ShouldBe(1001);
}
}
@@ -1,48 +1,48 @@
using ClosedXML.Excel;
using JdeScoping.ExcelIO.Tests.Fixtures;
using Shouldly;
using Xunit;
namespace JdeScoping.ExcelIO.Tests.Integration;
public class MinimalSearchTests : IClassFixture<MinimalSearchFixture>
{
private readonly XLWorkbook _workbook;
public MinimalSearchTests(MinimalSearchFixture fixture)
{
_workbook = fixture.Workbook;
}
[Fact]
public void SheetCount_IsTwo()
{
_workbook.Worksheets.Count.ShouldBe(2);
}
[Fact]
public void SearchCriteriaSheet_Exists()
{
_workbook.Worksheets.TryGetWorksheet("Search Criteria", out _).ShouldBeTrue();
}
[Fact]
public void SearchResultsSheet_Exists()
{
_workbook.Worksheets.TryGetWorksheet("Search Results", out _).ShouldBeTrue();
}
[Fact]
public void SearchCriteriaSheet_IsProtected()
{
var sheet = _workbook.Worksheet("Search Criteria");
sheet.Protection.IsProtected.ShouldBeTrue();
}
[Fact]
public void SearchResultsSheet_IsProtected()
{
var sheet = _workbook.Worksheet("Search Results");
sheet.Protection.IsProtected.ShouldBeTrue();
}
}
using JdeScoping.ExcelIO.Tests.Fixtures;
using NPOI.XSSF.UserModel;
using Shouldly;
using Xunit;
namespace JdeScoping.ExcelIO.Tests.Integration;
public class MinimalSearchTests : IClassFixture<MinimalSearchFixture>
{
private readonly XSSFWorkbook _workbook;
public MinimalSearchTests(MinimalSearchFixture fixture)
{
_workbook = fixture.Workbook;
}
[Fact]
public void SheetCount_IsTwo()
{
_workbook.NumberOfSheets.ShouldBe(2);
}
[Fact]
public void SearchCriteriaSheet_Exists()
{
_workbook.GetSheet("Search Criteria").ShouldNotBeNull();
}
[Fact]
public void SearchResultsSheet_Exists()
{
_workbook.GetSheet("Search Results").ShouldNotBeNull();
}
[Fact]
public void SearchCriteriaSheet_IsProtected()
{
var sheet = (XSSFSheet)_workbook.GetSheet("Search Criteria")!;
sheet.IsSheetLocked.ShouldBeTrue();
}
[Fact]
public void SearchResultsSheet_IsProtected()
{
var sheet = (XSSFSheet)_workbook.GetSheet("Search Results")!;
sheet.IsSheetLocked.ShouldBeTrue();
}
}
@@ -1,130 +1,131 @@
using ClosedXML.Excel;
using JdeScoping.ExcelIO.Tests.Fixtures;
using Shouldly;
using Xunit;
namespace JdeScoping.ExcelIO.Tests.Integration;
public class MisInfoSheetTests : IClassFixture<WithMisDataFixture>
{
private readonly XLWorkbook _workbook;
private readonly IXLWorksheet _sheet;
private readonly List<string> _headers;
public MisInfoSheetTests(WithMisDataFixture fixture)
{
_workbook = fixture.Workbook;
_sheet = _workbook.Worksheet("MIS Info");
_headers = ExcelTestHelpers.GetHeadersFromSheet(_sheet);
}
[Fact]
public void SheetCount_IsFour()
{
_workbook.Worksheets.Count.ShouldBe(4);
}
[Fact]
public void MisInfoSheet_Exists()
{
_workbook.Worksheets.TryGetWorksheet("MIS Info", out _).ShouldBeTrue();
}
[Fact]
public void ColumnCount_Is19()
{
_headers.Count.ShouldBe(19);
}
[Fact]
public void ColumnHeaders_MatchExpected()
{
_headers.ShouldContain("Item Number");
_headers.ShouldContain("MIS Job Step Sequence Number");
_headers.ShouldContain("MIS Number");
_headers.ShouldContain("MIS Revision");
_headers.ShouldContain("Item Description");
_headers.ShouldContain("MIS Release Status");
_headers.ShouldContain("MIS Release Date");
_headers.ShouldContain("Branch Code");
_headers.ShouldContain("Job Step Sequence Number");
_headers.ShouldContain("Matched Sequence Number");
_headers.ShouldContain("Matched to F3112Z1?");
_headers.ShouldContain("Matched to F3003?");
_headers.ShouldContain("Function Operation Description");
_headers.ShouldContain("Char Number");
_headers.ShouldContain("Test Description");
_headers.ShouldContain("Sampling Type");
_headers.ShouldContain("Sampling Value");
_headers.ShouldContain("Tools & Gauges");
_headers.ShouldContain("Work Instructions");
}
[Fact]
public void ColumnOrder_MatchesSpec()
{
_headers[0].ShouldBe("Item Number");
_headers[1].ShouldBe("MIS Job Step Sequence Number");
_headers[2].ShouldBe("MIS Number");
_headers[3].ShouldBe("MIS Revision");
_headers[4].ShouldBe("Item Description");
_headers[5].ShouldBe("MIS Release Status");
_headers[6].ShouldBe("MIS Release Date");
_headers[7].ShouldBe("Branch Code");
_headers[8].ShouldBe("Job Step Sequence Number");
_headers[9].ShouldBe("Matched Sequence Number");
_headers[10].ShouldBe("Matched to F3112Z1?");
_headers[11].ShouldBe("Matched to F3003?");
_headers[12].ShouldBe("Function Operation Description");
_headers[13].ShouldBe("Char Number");
_headers[14].ShouldBe("Test Description");
_headers[15].ShouldBe("Sampling Type");
_headers[16].ShouldBe("Sampling Value");
_headers[17].ShouldBe("Tools & Gauges");
_headers[18].ShouldBe("Work Instructions");
}
[Fact]
public void TableStyle_IsLight18()
{
var table = _sheet.Tables.First();
table.Theme.ShouldBe(XLTableTheme.TableStyleLight18);
}
[Fact]
public void Protection_IsEnabled()
{
_sheet.Protection.IsProtected.ShouldBeTrue();
}
[Fact]
public void DataRow_ContainsExpectedValues()
{
_sheet.Cell(2, 1).Value.GetText().ShouldBe("ITEM-001");
_sheet.Cell(2, 3).Value.GetText().ShouldBe("MIS-001");
}
[Fact]
public void TestDescriptionColumn_IsWrapped()
{
var colIndex = _headers.IndexOf("Test Description") + 1;
_sheet.Column(colIndex).Width.ShouldBe(65);
_sheet.Column(colIndex).Style.Alignment.WrapText.ShouldBeTrue();
}
[Fact]
public void ToolsGaugesColumn_IsWrapped()
{
var colIndex = _headers.IndexOf("Tools & Gauges") + 1;
_sheet.Column(colIndex).Width.ShouldBe(65);
_sheet.Column(colIndex).Style.Alignment.WrapText.ShouldBeTrue();
}
[Fact]
public void WorkInstructionsColumn_IsWrapped()
{
var colIndex = _headers.IndexOf("Work Instructions") + 1;
_sheet.Column(colIndex).Width.ShouldBe(65);
_sheet.Column(colIndex).Style.Alignment.WrapText.ShouldBeTrue();
}
}
using JdeScoping.ExcelIO.Tests.Fixtures;
using NPOI.SS.UserModel;
using NPOI.XSSF.UserModel;
using Shouldly;
using Xunit;
namespace JdeScoping.ExcelIO.Tests.Integration;
public class MisInfoSheetTests : IClassFixture<WithMisDataFixture>
{
private readonly XSSFWorkbook _workbook;
private readonly ISheet _sheet;
private readonly List<string> _headers;
public MisInfoSheetTests(WithMisDataFixture fixture)
{
_workbook = fixture.Workbook;
_sheet = _workbook.GetSheet("MIS Info")!;
_headers = ExcelTestHelpers.GetHeadersFromSheet(_sheet);
}
[Fact]
public void SheetCount_IsFour()
{
_workbook.NumberOfSheets.ShouldBe(4);
}
[Fact]
public void MisInfoSheet_Exists()
{
_workbook.GetSheet("MIS Info").ShouldNotBeNull();
}
[Fact]
public void ColumnCount_Is19()
{
_headers.Count.ShouldBe(19);
}
[Fact]
public void ColumnHeaders_MatchExpected()
{
_headers.ShouldContain("Item Number");
_headers.ShouldContain("MIS Job Step Sequence Number");
_headers.ShouldContain("MIS Number");
_headers.ShouldContain("MIS Revision");
_headers.ShouldContain("Item Description");
_headers.ShouldContain("MIS Release Status");
_headers.ShouldContain("MIS Release Date");
_headers.ShouldContain("Branch Code");
_headers.ShouldContain("Job Step Sequence Number");
_headers.ShouldContain("Matched Sequence Number");
_headers.ShouldContain("Matched to F3112Z1?");
_headers.ShouldContain("Matched to F3003?");
_headers.ShouldContain("Function Operation Description");
_headers.ShouldContain("Char Number");
_headers.ShouldContain("Test Description");
_headers.ShouldContain("Sampling Type");
_headers.ShouldContain("Sampling Value");
_headers.ShouldContain("Tools & Gauges");
_headers.ShouldContain("Work Instructions");
}
[Fact]
public void ColumnOrder_MatchesSpec()
{
_headers[0].ShouldBe("Item Number");
_headers[1].ShouldBe("MIS Job Step Sequence Number");
_headers[2].ShouldBe("MIS Number");
_headers[3].ShouldBe("MIS Revision");
_headers[4].ShouldBe("Item Description");
_headers[5].ShouldBe("MIS Release Status");
_headers[6].ShouldBe("MIS Release Date");
_headers[7].ShouldBe("Branch Code");
_headers[8].ShouldBe("Job Step Sequence Number");
_headers[9].ShouldBe("Matched Sequence Number");
_headers[10].ShouldBe("Matched to F3112Z1?");
_headers[11].ShouldBe("Matched to F3003?");
_headers[12].ShouldBe("Function Operation Description");
_headers[13].ShouldBe("Char Number");
_headers[14].ShouldBe("Test Description");
_headers[15].ShouldBe("Sampling Type");
_headers[16].ShouldBe("Sampling Value");
_headers[17].ShouldBe("Tools & Gauges");
_headers[18].ShouldBe("Work Instructions");
}
[Fact]
public void TableStyle_IsLight18()
{
var table = ExcelTestHelpers.GetFirstTable(_sheet);
table.StyleName.ShouldBe("TableStyleLight18");
}
[Fact]
public void Protection_IsEnabled()
{
((XSSFSheet)_sheet).IsSheetLocked.ShouldBeTrue();
}
[Fact]
public void DataRow_ContainsExpectedValues()
{
ExcelTestHelpers.GetCellText(_sheet, 2, 1).ShouldBe("ITEM-001");
ExcelTestHelpers.GetCellText(_sheet, 2, 3).ShouldBe("MIS-001");
}
[Fact]
public void TestDescriptionColumn_IsWrapped()
{
var colIndex = _headers.IndexOf("Test Description") + 1;
ExcelTestHelpers.GetColumnWidthChars(_sheet, colIndex).ShouldBe(65);
ExcelTestHelpers.GetCell(_sheet, 2, colIndex)!.CellStyle.WrapText.ShouldBeTrue();
}
[Fact]
public void ToolsGaugesColumn_IsWrapped()
{
var colIndex = _headers.IndexOf("Tools & Gauges") + 1;
ExcelTestHelpers.GetColumnWidthChars(_sheet, colIndex).ShouldBe(65);
ExcelTestHelpers.GetCell(_sheet, 2, colIndex)!.CellStyle.WrapText.ShouldBeTrue();
}
[Fact]
public void WorkInstructionsColumn_IsWrapped()
{
var colIndex = _headers.IndexOf("Work Instructions") + 1;
ExcelTestHelpers.GetColumnWidthChars(_sheet, colIndex).ShouldBe(65);
ExcelTestHelpers.GetCell(_sheet, 2, colIndex)!.CellStyle.WrapText.ShouldBeTrue();
}
}
@@ -1,75 +1,77 @@
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");
}
}
using JdeScoping.ExcelIO.Tests.Fixtures;
using NPOI.SS.UserModel;
using NPOI.XSSF.UserModel;
using Shouldly;
using Xunit;
namespace JdeScoping.ExcelIO.Tests.Integration;
public class ProtectionAndStyleTests : IClassFixture<WithMisDataFixture>
{
private readonly XSSFWorkbook _workbook;
public ProtectionAndStyleTests(WithMisDataFixture fixture)
{
_workbook = fixture.Workbook;
}
[Fact]
public void AllDataSheets_AreProtected()
{
((XSSFSheet)_workbook.GetSheet("Search Results")!).IsSheetLocked.ShouldBeTrue();
((XSSFSheet)_workbook.GetSheet("MIS Info")!).IsSheetLocked.ShouldBeTrue();
((XSSFSheet)_workbook.GetSheet("Investigation")!).IsSheetLocked.ShouldBeTrue();
}
[Fact]
public void Protection_AllowsFiltering()
{
var sheet = (XSSFSheet)_workbook.GetSheet("Search Results")!;
sheet.IsAutoFilterLocked.ShouldBeFalse();
}
[Fact]
public void Protection_AllowsSorting()
{
var sheet = (XSSFSheet)_workbook.GetSheet("Search Results")!;
sheet.IsSortLocked.ShouldBeFalse();
}
[Fact]
public void Protection_AllowsFormatting()
{
var sheet = (XSSFSheet)_workbook.GetSheet("Search Results")!;
sheet.IsFormatCellsLocked.ShouldBeFalse();
sheet.IsFormatColumnsLocked.ShouldBeFalse();
sheet.IsFormatRowsLocked.ShouldBeFalse();
}
[Fact]
public void AllTables_UseLight18Style()
{
ExcelTestHelpers.GetFirstTable(_workbook.GetSheet("Search Results")!).StyleName.ShouldBe("TableStyleLight18");
ExcelTestHelpers.GetFirstTable(_workbook.GetSheet("MIS Info")!).StyleName.ShouldBe("TableStyleLight18");
ExcelTestHelpers.GetFirstTable(_workbook.GetSheet("Investigation")!).StyleName.ShouldBe("TableStyleLight18");
}
[Fact]
public void HeaderCells_HaveCorrectFormatting()
{
var sheet = _workbook.GetSheet("Search Criteria")!;
var headerCell = ExcelTestHelpers.GetCell(sheet, 1, 1)!;
(headerCell.CellStyle.FontIndex >= 0 &&
_workbook.GetFontAt(headerCell.CellStyle.FontIndex).IsBold).ShouldBeTrue();
ExcelTestHelpers.GetFillForegroundRgb(headerCell).ShouldBe([0xDC, 0xDC, 0xDC]);
headerCell.CellStyle.Alignment.ShouldBe(HorizontalAlignment.Center);
}
[Fact]
public void CriteriaTimestamp_MatchesLegacyFormat()
{
var sheet = _workbook.GetSheet("Search Criteria")!;
var timestamp = ExcelTestHelpers.GetCellText(sheet, 4, 2);
timestamp.ShouldContain("Jan 15, 2024");
timestamp.ShouldContain("02:30:45");
timestamp.ShouldContain("EST");
}
}
@@ -1,89 +1,90 @@
using ClosedXML.Excel;
using JdeScoping.ExcelIO.Tests.Fixtures;
using Shouldly;
using Xunit;
namespace JdeScoping.ExcelIO.Tests.Integration;
public class SearchResultsSheetTests : IClassFixture<WithResultsFixture>
{
private readonly XLWorkbook _workbook;
private readonly IXLWorksheet _sheet;
private readonly List<string> _headers;
public SearchResultsSheetTests(WithResultsFixture fixture)
{
_workbook = fixture.Workbook;
_sheet = _workbook.Worksheet("Search Results");
_headers = ExcelTestHelpers.GetHeadersFromSheet(_sheet);
}
[Fact]
public void ColumnCount_Is19()
{
_headers.Count.ShouldBe(19);
}
[Fact]
public void ColumnHeaders_MatchExpected()
{
_headers.ShouldContain("Work Order Number");
_headers.ShouldContain("Work Order Branch Code");
_headers.ShouldContain("Lot Number");
_headers.ShouldContain("Item Number");
_headers.ShouldContain("Planning Family");
_headers.ShouldContain("Stocking Type");
_headers.ShouldContain("Order Quantity");
_headers.ShouldContain("Held Quantity");
_headers.ShouldContain("Scrapped Quantity");
_headers.ShouldContain("Shipped Quantity");
_headers.ShouldContain("Operation Step Branch Code");
_headers.ShouldContain("Operation Step");
_headers.ShouldContain("Operation Step Description");
_headers.ShouldContain("Function Operation Description");
_headers.ShouldContain("Operation Step Update Timestamp");
_headers.ShouldContain("Status Code");
_headers.ShouldContain("Status Description");
_headers.ShouldContain("Status Update Timestamp");
_headers.ShouldContain("Inclusion Reason");
}
[Fact]
public void ColumnOrder_MatchesSpec()
{
_headers[0].ShouldBe("Work Order Number");
_headers[1].ShouldBe("Work Order Branch Code");
_headers[2].ShouldBe("Lot Number");
_headers[3].ShouldBe("Item Number");
_headers[4].ShouldBe("Planning Family");
_headers[5].ShouldBe("Stocking Type");
_headers[6].ShouldBe("Order Quantity");
_headers[7].ShouldBe("Held Quantity");
_headers[8].ShouldBe("Scrapped Quantity");
_headers[9].ShouldBe("Shipped Quantity");
_headers[10].ShouldBe("Operation Step Branch Code");
_headers[11].ShouldBe("Operation Step");
_headers[12].ShouldBe("Operation Step Description");
_headers[13].ShouldBe("Function Operation Description");
_headers[14].ShouldBe("Operation Step Update Timestamp");
_headers[15].ShouldBe("Status Code");
_headers[16].ShouldBe("Status Description");
_headers[17].ShouldBe("Status Update Timestamp");
_headers[18].ShouldBe("Inclusion Reason");
}
[Fact]
public void TableStyle_IsLight18()
{
var table = _sheet.Tables.First();
table.Theme.ShouldBe(XLTableTheme.TableStyleLight18);
}
[Fact]
public void DataRow_ContainsExpectedValues()
{
_sheet.Cell(2, 1).Value.GetNumber().ShouldBe(12345);
_sheet.Cell(2, 3).Value.GetText().ShouldBe("LOT-001");
_sheet.Cell(2, 4).Value.GetText().ShouldBe("ITEM-001");
}
}
using JdeScoping.ExcelIO.Tests.Fixtures;
using NPOI.SS.UserModel;
using NPOI.XSSF.UserModel;
using Shouldly;
using Xunit;
namespace JdeScoping.ExcelIO.Tests.Integration;
public class SearchResultsSheetTests : IClassFixture<WithResultsFixture>
{
private readonly XSSFWorkbook _workbook;
private readonly ISheet _sheet;
private readonly List<string> _headers;
public SearchResultsSheetTests(WithResultsFixture fixture)
{
_workbook = fixture.Workbook;
_sheet = _workbook.GetSheet("Search Results")!;
_headers = ExcelTestHelpers.GetHeadersFromSheet(_sheet);
}
[Fact]
public void ColumnCount_Is19()
{
_headers.Count.ShouldBe(19);
}
[Fact]
public void ColumnHeaders_MatchExpected()
{
_headers.ShouldContain("Work Order Number");
_headers.ShouldContain("Work Order Branch Code");
_headers.ShouldContain("Lot Number");
_headers.ShouldContain("Item Number");
_headers.ShouldContain("Planning Family");
_headers.ShouldContain("Stocking Type");
_headers.ShouldContain("Order Quantity");
_headers.ShouldContain("Held Quantity");
_headers.ShouldContain("Scrapped Quantity");
_headers.ShouldContain("Shipped Quantity");
_headers.ShouldContain("Operation Step Branch Code");
_headers.ShouldContain("Operation Step");
_headers.ShouldContain("Operation Step Description");
_headers.ShouldContain("Function Operation Description");
_headers.ShouldContain("Operation Step Update Timestamp");
_headers.ShouldContain("Status Code");
_headers.ShouldContain("Status Description");
_headers.ShouldContain("Status Update Timestamp");
_headers.ShouldContain("Inclusion Reason");
}
[Fact]
public void ColumnOrder_MatchesSpec()
{
_headers[0].ShouldBe("Work Order Number");
_headers[1].ShouldBe("Work Order Branch Code");
_headers[2].ShouldBe("Lot Number");
_headers[3].ShouldBe("Item Number");
_headers[4].ShouldBe("Planning Family");
_headers[5].ShouldBe("Stocking Type");
_headers[6].ShouldBe("Order Quantity");
_headers[7].ShouldBe("Held Quantity");
_headers[8].ShouldBe("Scrapped Quantity");
_headers[9].ShouldBe("Shipped Quantity");
_headers[10].ShouldBe("Operation Step Branch Code");
_headers[11].ShouldBe("Operation Step");
_headers[12].ShouldBe("Operation Step Description");
_headers[13].ShouldBe("Function Operation Description");
_headers[14].ShouldBe("Operation Step Update Timestamp");
_headers[15].ShouldBe("Status Code");
_headers[16].ShouldBe("Status Description");
_headers[17].ShouldBe("Status Update Timestamp");
_headers[18].ShouldBe("Inclusion Reason");
}
[Fact]
public void TableStyle_IsLight18()
{
var table = ExcelTestHelpers.GetFirstTable(_sheet);
table.StyleName.ShouldBe("TableStyleLight18");
}
[Fact]
public void DataRow_ContainsExpectedValues()
{
ExcelTestHelpers.GetCellNumber(_sheet, 2, 1).ShouldBe(12345);
ExcelTestHelpers.GetCellText(_sheet, 2, 3).ShouldBe("LOT-001");
ExcelTestHelpers.GetCellText(_sheet, 2, 4).ShouldBe("ITEM-001");
}
}