- Add StorageCsvExportService, StorageHtmlExportService stub (Plan 03-03) - Add SearchCsvExportService, SearchHtmlExportService stub (Plan 03-05) - Add DuplicatesHtmlExportService stub (Plan 03-05) - Add StorageServiceTests, SearchServiceTests, DuplicatesServiceTests scaffolds - Add export test scaffolds for all 4 Phase 3 export services - 7 pure-logic tests pass (VersionSizeBytes + MakeKey); 4 CSOM stubs skip
53 lines
1.8 KiB
C#
53 lines
1.8 KiB
C#
using SharepointToolbox.Core.Models;
|
|
using SharepointToolbox.Services.Export;
|
|
using Xunit;
|
|
|
|
namespace SharepointToolbox.Tests.Services.Export;
|
|
|
|
public class StorageCsvExportServiceTests
|
|
{
|
|
[Fact]
|
|
public void BuildCsv_WithKnownNodes_ProducesHeaderRow()
|
|
{
|
|
var svc = new StorageCsvExportService();
|
|
var nodes = new List<StorageNode>
|
|
{
|
|
new() { Name = "Shared Documents", Library = "Shared Documents", SiteTitle = "MySite",
|
|
TotalSizeBytes = 1024, FileStreamSizeBytes = 800, TotalFileCount = 5,
|
|
LastModified = new DateTime(2024, 1, 15) }
|
|
};
|
|
var csv = svc.BuildCsv(nodes);
|
|
Assert.Contains("Library", csv);
|
|
Assert.Contains("Site", csv);
|
|
Assert.Contains("Files", csv);
|
|
Assert.Contains("Total Size", csv);
|
|
Assert.Contains("Version Size", csv);
|
|
Assert.Contains("Last Modified", csv);
|
|
}
|
|
|
|
[Fact]
|
|
public void BuildCsv_WithEmptyList_ReturnsHeaderOnly()
|
|
{
|
|
var svc = new StorageCsvExportService();
|
|
var csv = svc.BuildCsv(new List<StorageNode>());
|
|
Assert.NotEmpty(csv); // must have at least the header row
|
|
var lines = csv.Split('\n', StringSplitOptions.RemoveEmptyEntries);
|
|
Assert.Single(lines); // only header, no data rows
|
|
}
|
|
|
|
[Fact]
|
|
public void BuildCsv_NodeValues_AppearInOutput()
|
|
{
|
|
var svc = new StorageCsvExportService();
|
|
var nodes = new List<StorageNode>
|
|
{
|
|
new() { Name = "Reports", Library = "Reports", SiteTitle = "ProjectSite",
|
|
TotalSizeBytes = 2048, FileStreamSizeBytes = 1024, TotalFileCount = 10 }
|
|
};
|
|
var csv = svc.BuildCsv(nodes);
|
|
Assert.Contains("Reports", csv);
|
|
Assert.Contains("ProjectSite", csv);
|
|
Assert.Contains("10", csv);
|
|
}
|
|
}
|