using SharepointToolbox.Core.Models;
using SharepointToolbox.Services.Export;
namespace SharepointToolbox.Tests.Services.Export;
///
/// Tests for PERM-06: HTML export output.
/// These tests reference HtmlExportService which will be implemented in Plan 03.
/// Until Plan 03 runs they will fail to compile — that is expected.
///
public class HtmlExportServiceTests
{
private static PermissionEntry MakeEntry(
string users, string userLogins,
string url = "https://contoso.sharepoint.com/sites/A") =>
new("Web", "Site A", url, true, users, userLogins, "Read", "Direct Permissions", "User");
private static ReportBranding MakeBranding(bool msp = true, bool client = false)
{
var mspLogo = msp ? new LogoData { Base64 = "bXNw", MimeType = "image/png" } : null;
var clientLogo = client ? new LogoData { Base64 = "Y2xpZW50", MimeType = "image/jpeg" } : null;
return new ReportBranding(mspLogo, clientLogo);
}
[Fact]
public void BuildHtml_WithKnownEntries_ContainsUserNames()
{
var entry = MakeEntry("Bob Smith", "bob@contoso.com");
var svc = new HtmlExportService();
var html = svc.BuildHtml(new[] { entry });
Assert.Contains("Bob Smith", html);
}
[Fact]
public void BuildHtml_WithEmptyList_ReturnsValidHtml()
{
var svc = new HtmlExportService();
var html = svc.BuildHtml(Array.Empty());
// Must be non-empty well-formed HTML even with no data rows
Assert.NotEmpty(html);
Assert.Contains("