feat(11-01): add ReportBranding model and BrandingHtmlHelper with tests

- Add ReportBranding positional record bundling MspLogo and ClientLogo
- Add BrandingHtmlHelper static class generating flex branding header HTML
- Add BrandingHtmlHelperTests covering all 4 logo states (null, both null, single, both)
- Add InternalsVisibleTo for SharepointToolbox.Tests in project file
This commit is contained in:
Dev
2026-04-08 14:34:45 +02:00
parent 9e850b07f2
commit 212c43915e
4 changed files with 156 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
namespace SharepointToolbox.Core.Models;
/// <summary>
/// Bundles MSP and client logos for passing to export services.
/// Export services receive this as a simple DTO — they don't know
/// about IBrandingService or ProfileService.
/// </summary>
public record ReportBranding(LogoData? MspLogo, LogoData? ClientLogo);

View File

@@ -0,0 +1,37 @@
using System.Text;
using SharepointToolbox.Core.Models;
namespace SharepointToolbox.Services.Export;
/// <summary>
/// Generates the branding header HTML fragment for HTML reports.
/// Called by each HTML export service between &lt;body&gt; and &lt;h1&gt;.
/// Returns empty string when no logos are configured (no broken images).
/// </summary>
internal static class BrandingHtmlHelper
{
public static string BuildBrandingHeader(ReportBranding? branding)
{
if (branding is null) return string.Empty;
var msp = branding.MspLogo;
var client = branding.ClientLogo;
if (msp is null && client is null) return string.Empty;
var sb = new StringBuilder();
sb.AppendLine("<div style=\"display:flex;gap:16px;align-items:center;padding:12px 24px 0;\">");
if (msp is not null)
sb.AppendLine($" <img src=\"data:{msp.MimeType};base64,{msp.Base64}\" alt=\"\" style=\"max-height:60px;max-width:200px;object-fit:contain;\">");
if (msp is not null && client is not null)
sb.AppendLine(" <div style=\"flex:1\"></div>");
if (client is not null)
sb.AppendLine($" <img src=\"data:{client.MimeType};base64,{client.Base64}\" alt=\"\" style=\"max-height:60px;max-width:200px;object-fit:contain;\">");
sb.AppendLine("</div>");
return sb.ToString();
}
}

View File

@@ -18,6 +18,12 @@
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
</PropertyGroup>
<ItemGroup>
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleToAttribute">
<_Parameter1>SharepointToolbox.Tests</_Parameter1>
</AssemblyAttribute>
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Remove="App.xaml" />
<Page Include="App.xaml" />