using System.Net; using System.Net.Http.Json; using System.Reflection; using System.Runtime.Versioning; using MeetingAssistant.MacOs; using MeetingAssistant.Notifications; using MeetingAssistant.Recording; using Microsoft.Extensions.DependencyInjection; using Xunit.Abstractions; namespace MeetingAssistant.Tests; public sealed class TestTargetCompositionTests(ITestOutputHelper output) { [Fact] public async Task TestAndApplicationTargetsUseMatchingComposition() { var testAssembly = typeof(TestTargetCompositionTests).Assembly; var applicationAssembly = typeof(Program).Assembly; var testFramework = testAssembly.GetCustomAttribute()?.FrameworkName; var applicationFramework = applicationAssembly.GetCustomAttribute()?.FrameworkName; var testPlatform = testAssembly.GetCustomAttribute()?.PlatformName; var applicationPlatform = applicationAssembly.GetCustomAttribute()?.PlatformName; output.WriteLine($"Test framework: {testFramework}; platform: {testPlatform ?? "portable"}"); output.WriteLine($"Application framework: {applicationFramework}; platform: {applicationPlatform ?? "portable"}"); Assert.Equal(".NETCoreApp,Version=v10.0", testFramework); Assert.Equal(testFramework, applicationFramework); Assert.Equal(testPlatform, applicationPlatform); #if WINDOWS Assert.Equal("Windows10.0.19041.0", testPlatform, ignoreCase: true); #else Assert.Null(testPlatform); #endif await using var factory = new IsolatedApplicationFactory(); using var client = factory.CreateClient(); using var health = await client.GetAsync("/health"); var capabilities = await client.GetFromJsonAsync("/diagnostics/platform-capabilities"); using var requests = await client.GetAsync("/desktop/requests"); Assert.Equal(HttpStatusCode.OK, health.StatusCode); Assert.NotNull(capabilities); #if WINDOWS Assert.Equal("OutlookClassicMeetingMetadataProvider", capabilities.MeetingMetadataProvider); Assert.Equal("WpfWorkflowRulesEditorWindowService", capabilities.WorkflowEditorProvider); Assert.IsType(factory.Services.GetRequiredService()); Assert.IsType(factory.Services.GetRequiredService()); Assert.Equal(HttpStatusCode.NotFound, requests.StatusCode); const string target = "windows"; #else Assert.Equal("MacOsWorkflowRulesEditorWindowService", capabilities.WorkflowEditorProvider); Assert.Equal(HttpStatusCode.OK, requests.StatusCode); if (OperatingSystem.IsMacOS()) { Assert.Equal("MacOsMeetingMetadataProvider", capabilities.MeetingMetadataProvider); Assert.IsType(factory.Services.GetRequiredService()); Assert.IsType(factory.Services.GetRequiredService()); } else { Assert.Equal("NoopMeetingMetadataProvider", capabilities.MeetingMetadataProvider); Assert.IsType(factory.Services.GetRequiredService()); Assert.IsType(factory.Services.GetRequiredService()); } const string target = "portable"; #endif var host = OperatingSystem.IsWindows() ? "windows" : OperatingSystem.IsMacOS() ? "macos" : OperatingSystem.IsLinux() ? "linux" : "other"; output.WriteLine($"platform-assurance: target={target}; host={host}"); } }