From 6eed5187468b46f416837afc718bf1ff2d5bc450 Mon Sep 17 00:00:00 2001 From: artyom Date: Sun, 30 Jun 2019 21:08:12 +0300 Subject: [PATCH] Indicate exotic lifetimes are not supported --- .../AutoSuspendHelperTest.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/Avalonia.ReactiveUI.UnitTests/AutoSuspendHelperTest.cs b/tests/Avalonia.ReactiveUI.UnitTests/AutoSuspendHelperTest.cs index 142eba41d5..876f37cc9e 100644 --- a/tests/Avalonia.ReactiveUI.UnitTests/AutoSuspendHelperTest.cs +++ b/tests/Avalonia.ReactiveUI.UnitTests/AutoSuspendHelperTest.cs @@ -36,6 +36,11 @@ namespace Avalonia.ReactiveUI.UnitTests public string Example { get; set; } } + public class ExoticApplicationLifetimeWithoutLifecycleEvents : IDisposable, IApplicationLifetime + { + public void Dispose() { } + } + [Fact] public void AutoSuspendHelper_Should_Immediately_Fire_IsLaunchingNew() { @@ -77,5 +82,17 @@ namespace Avalonia.ReactiveUI.UnitTests Assert.Equal("Foo", RxApp.SuspensionHost.GetAppState().Example); } } + + [Fact] + public void AutoSuspendHelper_Should_Throw_For_Not_Supported_Lifetimes() + { + using (UnitTestApplication.Start(TestServices.MockWindowingPlatform)) + using (var lifetime = new ExoticApplicationLifetimeWithoutLifecycleEvents()) + { + var application = AvaloniaLocator.Current.GetService(); + application.ApplicationLifetime = lifetime; + Assert.Throws(() => new AutoSuspendHelper(application.ApplicationLifetime)); + } + } } } \ No newline at end of file