feat(11-04): add UpdateProfileAsync to ProfileService and ImportLogoFromBytesAsync to BrandingService

- ProfileService.UpdateProfileAsync: replaces profile by name and persists the change
- IBrandingService: add ImportLogoFromBytesAsync to interface contract
- BrandingService.ImportLogoFromBytesAsync: validates magic bytes, compresses if > 512KB, returns LogoData
- BrandingService.ImportLogoAsync: refactored to delegate to ImportLogoFromBytesAsync
- ProfileServiceTests: 2 new tests (UpdateProfileAsync happy path + KeyNotFoundException)
- BrandingServiceTests: 2 new tests (ImportLogoFromBytesAsync valid PNG + invalid bytes)
- Tests.csproj: suppress NU1701 for pre-existing LiveCharts2/OpenTK transitive warnings
This commit is contained in:
Dev
2026-04-08 14:34:11 +02:00
parent 1ab2f2e426
commit 9e850b07f2
6 changed files with 69 additions and 2 deletions

View File

@@ -147,6 +147,32 @@ public class ProfileServiceTests : IDisposable
await Assert.ThrowsAsync<KeyNotFoundException>(() => service.DeleteProfileAsync("NonExistent"));
}
[Fact]
public async Task UpdateProfileAsync_UpdatesExistingProfile_AndPersists()
{
var service = CreateService();
var profile = new TenantProfile { Name = "UpdateMe", TenantUrl = "https://update.sharepoint.com", ClientId = "cid-update" };
await service.AddProfileAsync(profile);
// Mutate — set a ClientLogo to simulate logo update
profile.ClientLogo = new SharepointToolbox.Core.Models.LogoData { Base64 = "abc==", MimeType = "image/png" };
await service.UpdateProfileAsync(profile);
var profiles = await service.GetProfilesAsync();
Assert.Single(profiles);
Assert.NotNull(profiles[0].ClientLogo);
Assert.Equal("abc==", profiles[0].ClientLogo!.Base64);
}
[Fact]
public async Task UpdateProfileAsync_ProfileNotFound_ThrowsKeyNotFoundException()
{
var service = CreateService();
var profile = new TenantProfile { Name = "NonExistent", TenantUrl = "https://x.sharepoint.com", ClientId = "cid" };
await Assert.ThrowsAsync<KeyNotFoundException>(() => service.UpdateProfileAsync(profile));
}
[Fact]
public async Task SaveAsync_JsonOutput_UsesProfilesRootKey()
{