Files
AtomUI/tests/AtomUI.Core.Tests/Application/ImageLoadingApplicationBuilderTests.cs
2026-10-20 14:03:47 +08:00

39 lines
1.3 KiB
C#

using AtomUI.Controls;
using Shouldly;
using Xunit;
namespace AtomUI.Core.Tests.AppLifecycle;
public class ImageLoadingApplicationBuilderTests
{
[Fact]
public void Independent_UseAtomUI_Builders_Publish_Separate_Image_Loaders()
{
HeadlessTestApp.Run(() =>
{
var firstApplication = new Avalonia.Application();
var secondApplication = new Avalonia.Application();
try
{
ApplicationStartup.AttachWith(firstApplication, builder => builder.UseImageLoading());
ApplicationStartup.AttachWith(secondApplication, builder => builder.UseImageLoading());
var firstLoader = firstApplication.GetImageLoader();
var secondLoader = secondApplication.GetImageLoader();
firstLoader.ShouldNotBeSameAs(secondLoader);
firstLoader.Snapshot.ShouldBe(default(ImageLoaderSnapshot));
secondLoader.Snapshot.ShouldBe(default(ImageLoaderSnapshot));
}
finally
{
ApplicationScopeRegistry.Get(secondApplication)?.Dispose();
ApplicationScopeRegistry.Get(firstApplication)?.Dispose();
}
firstApplication.TryGetImageLoader().ShouldBeNull();
secondApplication.TryGetImageLoader().ShouldBeNull();
});
}
}