Browse Source

Indicate exotic lifetimes are not supported

pull/2672/head
artyom 7 years ago
parent
commit
6eed518746
  1. 17
      tests/Avalonia.ReactiveUI.UnitTests/AutoSuspendHelperTest.cs

17
tests/Avalonia.ReactiveUI.UnitTests/AutoSuspendHelperTest.cs

@ -36,6 +36,11 @@ namespace Avalonia.ReactiveUI.UnitTests
public string Example { get; set; } public string Example { get; set; }
} }
public class ExoticApplicationLifetimeWithoutLifecycleEvents : IDisposable, IApplicationLifetime
{
public void Dispose() { }
}
[Fact] [Fact]
public void AutoSuspendHelper_Should_Immediately_Fire_IsLaunchingNew() public void AutoSuspendHelper_Should_Immediately_Fire_IsLaunchingNew()
{ {
@ -77,5 +82,17 @@ namespace Avalonia.ReactiveUI.UnitTests
Assert.Equal("Foo", RxApp.SuspensionHost.GetAppState<AppState>().Example); Assert.Equal("Foo", RxApp.SuspensionHost.GetAppState<AppState>().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>();
application.ApplicationLifetime = lifetime;
Assert.Throws<NotSupportedException>(() => new AutoSuspendHelper(application.ApplicationLifetime));
}
}
} }
} }
Loading…
Cancel
Save