using System.Runtime.CompilerServices; using Livia.Models; using Livia.Models.Data; using Livia.Properties; using Livia.ViewModels; using Livia.Views.Utility; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Xunit.DependencyInjection; namespace MdpC2.Tests; internal class Startup { public void ConfigureServices(IServiceCollection serviceCollection) { serviceCollection.AddSingleton(svc => svc.GetRequiredService>()); serviceCollection.AddSingleton(); serviceCollection.AddSingleton(); serviceCollection.AddSingleton(); serviceCollection.AddSingleton(); serviceCollection.AddSingleton(); serviceCollection.AddSingleton(); serviceCollection.AddSingleton(); serviceCollection.AddSingleton(); serviceCollection.AddSingleton(); serviceCollection.AddHttpClient(x => { x.Timeout = TimeSpan.FromMinutes(10); UriBuilder uriBuilder = new() { Scheme = Settings.Default.ServerPort == 443 ? "https" : "http", Host = Settings.Default.ServerAddress, Port = Settings.Default.ServerPort }; x.BaseAddress = uriBuilder.Uri; }); serviceCollection.AddSingleton(); serviceCollection.AddSingleton(); serviceCollection.AddStaFactSupport(); } } public class UnitTest1(ILogger logger, IIdleTimer idleTimer, IWarningSystem warningSystem) { private readonly ILogger _logger = logger; private readonly IIdleTimer _idleTimer = idleTimer; private readonly IWarningSystem _warningSystem = warningSystem; [ModuleInitializer] public static void Init() => VerifyXaml.Initialize(); [WpfFact] public async Task WpfFact_OnSTAThread() { Assert.Equal(ApartmentState.STA, Thread.CurrentThread.GetApartmentState()); Assert.IsType(SynchronizationContext.Current); await Task.Yield(); Assert.Equal(ApartmentState.STA, Thread.CurrentThread.GetApartmentState()); // still there Assert.IsType(SynchronizationContext.Current); //var window = new MainWindow(_logger, _idleTimer, _warningSystem); //await Verify(window); } }