diff --git a/tests/Avalonia.ReactiveUI.UnitTests/AvaloniaActivationForViewFetcherTest.cs b/tests/Avalonia.ReactiveUI.UnitTests/AvaloniaActivationForViewFetcherTest.cs index a3c6b1a44a..f07378fe0c 100644 --- a/tests/Avalonia.ReactiveUI.UnitTests/AvaloniaActivationForViewFetcherTest.cs +++ b/tests/Avalonia.ReactiveUI.UnitTests/AvaloniaActivationForViewFetcherTest.cs @@ -71,25 +71,35 @@ namespace Avalonia Assert.Equal(2, activated.Count); } + [Fact] + public void GetAffinityForViewShouldReturnNonZeroForVisualElements() + { + var userControl = new TestUserControl(); + var activationForViewFetcher = new AvaloniaActivationForViewFetcher(); + + var forUserControl = activationForViewFetcher.GetAffinityForView(userControl.GetType()); + var forNonUserControl = activationForViewFetcher.GetAffinityForView(typeof(object)); + + Assert.NotEqual(0, forUserControl); + Assert.Equal(0, forNonUserControl); + } + [Fact] public void ActivationForViewFetcherShouldSupportWhenActivated() { - var locator = new ModernDependencyResolver(); - locator.InitializeSplat(); - locator.InitializeReactiveUI(); - locator.RegisterConstant(new AvaloniaActivationForViewFetcher(), typeof(IActivationForViewFetcher)); - using (locator.WithResolver()) - { - var userControl = new TestUserControlWithWhenActivated(); - Assert.False(userControl.Active); + Locator.CurrentMutable.RegisterConstant( + new AvaloniaActivationForViewFetcher(), + typeof(IActivationForViewFetcher)); - var fakeRenderedDecorator = new FakeRenderDecorator(); - fakeRenderedDecorator.Child = userControl; - Assert.True(userControl.Active); + var userControl = new TestUserControlWithWhenActivated(); + Assert.False(userControl.Active); - fakeRenderedDecorator.Child = null; - Assert.False(userControl.Active); - } + var fakeRenderedDecorator = new FakeRenderDecorator(); + fakeRenderedDecorator.Child = userControl; + Assert.True(userControl.Active); + + fakeRenderedDecorator.Child = null; + Assert.False(userControl.Active); } } } \ No newline at end of file