From 6a09b9ba6b618603a4eee718c8a85e3753706022 Mon Sep 17 00:00:00 2001 From: Dan Siegel Date: Sat, 26 Aug 2023 11:31:34 -0600 Subject: [PATCH] chore: updating tests for namespace & type name breaks --- .../Regions/Adapters/IRegionAdapter.cs | 18 -- .../Regions/Adapters/RegionAdapterBase.cs | 2 +- .../Fixtures/Regions/RegionFixture.cs | 2 +- .../ViewModels/Issue2415PageViewModel.cs | 4 +- .../Mocks/MockPresentationRegion.cs | 23 ++- .../Mocks/MockRegion.cs | 22 +-- .../Mocks/MockRegionAdapter.cs | 7 +- .../Mocks/MockRegionBehaviorCollection.cs | 2 +- .../Mocks/MockViewsCollection.cs | 8 +- .../LocatorNavigationTargetHandlerFixture.cs | 8 +- .../Tests/NavigationAsyncExtensionsFixture.cs | 9 +- .../Tests/RegionBehaviorCollectionFixture.cs | 2 +- .../Tests/RegionBehaviorFactoryFixture.cs | 2 +- .../Tests/RegionBehaviorFixture.cs | 1 + .../Tests/RegionFixture.cs | 2 +- .../Tests/RegionManagerFixture.cs | 11 +- .../RegionManagerRequestNavigateFixture.cs | 20 +- .../Tests/RegionNavigationJournalFixture.cs | 145 +++++++-------- .../Tests/RegionNavigationServiceFixture.cs | 173 +++++++++--------- .../Tests/RegionViewRegistryFixture.cs | 2 +- .../Fixtures/Regions/RegionFixture.cs | 3 +- .../ViewModels/MockRegionViewAViewModel.cs | 6 +- .../Mocks/MockRegionManager.cs | 6 + .../Mocks/MockRegionManager.cs | 3 +- .../AutoPopulateRegionBehaviorFixture.cs | 12 +- ...egionManagerRegistrationBehaviorFixture.cs | 3 +- .../NavigationAsyncExtensionsFixture.cs | 1 + .../Prism.Wpf.Tests/Regions/RegionFixture.cs | 2 +- .../Regions/RegionManagerFixture.cs | 15 +- .../RegionManagerRequestNavigateFixture.cs | 8 +- .../RegionNavigationServiceFixture.new.cs | 45 ++--- .../Regions/RegionViewRegistryFixture.cs | 2 +- 32 files changed, 294 insertions(+), 275 deletions(-) delete mode 100644 src/Forms/Prism.Forms.Regions/Regions/Adapters/IRegionAdapter.cs diff --git a/src/Forms/Prism.Forms.Regions/Regions/Adapters/IRegionAdapter.cs b/src/Forms/Prism.Forms.Regions/Regions/Adapters/IRegionAdapter.cs deleted file mode 100644 index 70387f79..00000000 --- a/src/Forms/Prism.Forms.Regions/Regions/Adapters/IRegionAdapter.cs +++ /dev/null @@ -1,18 +0,0 @@ -using Xamarin.Forms; - -namespace Prism.Regions.Adapters -{ - /// - /// Defines an interfaces to adapt an object and bind it to a new . - /// - public interface IRegionAdapter - { - /// - /// Adapts an object and binds it to a new . - /// - /// The object to adapt. - /// The name of the region to be created. - /// The new instance of that the is bound to. - IRegion Initialize(VisualElement regionTarget, string regionName); - } -} diff --git a/src/Forms/Prism.Forms.Regions/Regions/Adapters/RegionAdapterBase.cs b/src/Forms/Prism.Forms.Regions/Regions/Adapters/RegionAdapterBase.cs index 750194d9..7ca851c3 100644 --- a/src/Forms/Prism.Forms.Regions/Regions/Adapters/RegionAdapterBase.cs +++ b/src/Forms/Prism.Forms.Regions/Regions/Adapters/RegionAdapterBase.cs @@ -55,7 +55,7 @@ namespace Prism.Regions.Adapters /// is of type . /// When is . /// When is not of type . - IRegion IRegionAdapter.Initialize(VisualElement regionTarget, string regionName) + IRegion IRegionAdapter.Initialize(object regionTarget, string regionName) { return Initialize(GetCastedObject(regionTarget), regionName); } diff --git a/tests/Forms/Prism.DI.Forms.Tests/Fixtures/Regions/RegionFixture.cs b/tests/Forms/Prism.DI.Forms.Tests/Fixtures/Regions/RegionFixture.cs index 9377d62e..a0a9fe6c 100644 --- a/tests/Forms/Prism.DI.Forms.Tests/Fixtures/Regions/RegionFixture.cs +++ b/tests/Forms/Prism.DI.Forms.Tests/Fixtures/Regions/RegionFixture.cs @@ -31,7 +31,7 @@ namespace Prism.DI.Forms.Tests.Fixtures.Regions var vm = _app.MainPage.BindingContext as Issue2415PageViewModel; Assert.NotNull(vm.Result); - Assert.True(vm.Result.Result); + Assert.True(vm.Result.Success); } void IPlatformInitializer.RegisterTypes(IContainerRegistry containerRegistry) diff --git a/tests/Forms/Prism.DI.Forms.Tests/Mocks/ViewModels/Issue2415PageViewModel.cs b/tests/Forms/Prism.DI.Forms.Tests/Mocks/ViewModels/Issue2415PageViewModel.cs index c026bfae..8bd37abb 100644 --- a/tests/Forms/Prism.DI.Forms.Tests/Mocks/ViewModels/Issue2415PageViewModel.cs +++ b/tests/Forms/Prism.DI.Forms.Tests/Mocks/ViewModels/Issue2415PageViewModel.cs @@ -18,14 +18,14 @@ namespace Prism.DI.Forms.Tests.Mocks.ViewModels _regionManager = regionManager; } - public IRegionNavigationResult Result { get; private set; } + public NavigationResult Result { get; private set; } public void Initialize(INavigationParameters parameters) { _regionManager.RequestNavigate("ContentRegion", "Issue2415RegionView", NavigationCallback); } - private void NavigationCallback(IRegionNavigationResult result) + private void NavigationCallback(NavigationResult result) { Result = result; } diff --git a/tests/Forms/Prism.Forms.Regions.Tests/Mocks/MockPresentationRegion.cs b/tests/Forms/Prism.Forms.Regions.Tests/Mocks/MockPresentationRegion.cs index b27a74ba..f9d068c3 100644 --- a/tests/Forms/Prism.Forms.Regions.Tests/Mocks/MockPresentationRegion.cs +++ b/tests/Forms/Prism.Forms.Regions.Tests/Mocks/MockPresentationRegion.cs @@ -17,35 +17,35 @@ namespace Prism.Forms.Regions.Mocks { Behaviors = new MockRegionBehaviorCollection(); } - public IRegionManager Add(VisualElement view) + public IRegionManager Add(object view) { MockViews.Items.Add(view); return null; } - public void Remove(VisualElement view) + public void Remove(object view) { MockViews.Items.Remove(view); MockActiveViews.Items.Remove(view); } - public void Activate(VisualElement view) + public void Activate(object view) { MockActiveViews.Items.Add(view); } - public IRegionManager Add(VisualElement view, string viewName) + public IRegionManager Add(object view, string viewName) { throw new NotImplementedException(); } - public IRegionManager Add(VisualElement view, string viewName, bool createRegionManagerScope) + public IRegionManager Add(object view, string viewName, bool createRegionManagerScope) { throw new NotImplementedException(); } - public VisualElement GetView(string viewName) + public object GetView(string viewName) { throw new NotImplementedException(); } @@ -103,12 +103,12 @@ namespace Prism.Forms.Regions.Mocks throw new NotImplementedException(); } - public void RequestNavigate(Uri target, Action navigationCallback) + public void RequestNavigate(Uri target, Action navigationCallback) { throw new NotImplementedException(); } - public void RequestNavigate(Uri target, Action navigationCallback, INavigationParameters navigationParameters) + public void RequestNavigate(Uri target, Action navigationCallback, INavigationParameters navigationParameters) { throw new NotImplementedException(); } @@ -118,6 +118,11 @@ namespace Prism.Forms.Regions.Mocks throw new NotImplementedException(); } + public void Deactivate(object view) + { + throw new NotImplementedException(); + } + public IRegionNavigationService NavigationService { get => throw new NotImplementedException(); @@ -125,7 +130,7 @@ namespace Prism.Forms.Regions.Mocks } - public Comparison SortComparison + public Comparison SortComparison { get => throw new NotImplementedException(); set => throw new NotImplementedException(); diff --git a/tests/Forms/Prism.Forms.Regions.Tests/Mocks/MockRegion.cs b/tests/Forms/Prism.Forms.Regions.Tests/Mocks/MockRegion.cs index ae6208a8..4dd6d763 100644 --- a/tests/Forms/Prism.Forms.Regions.Tests/Mocks/MockRegion.cs +++ b/tests/Forms/Prism.Forms.Regions.Tests/Mocks/MockRegion.cs @@ -11,7 +11,7 @@ namespace Prism.Forms.Regions.Mocks internal class MockRegion : IRegion { public event PropertyChangedEventHandler PropertyChanged; - public Func GetViewStringDelegate { get; set; } + public Func GetViewStringDelegate { get; set; } private MockViewsCollection _views = new MockViewsCollection(); @@ -33,38 +33,38 @@ namespace Prism.Forms.Regions.Mocks public string Name { get; set; } - public IRegionManager Add(VisualElement view) + public IRegionManager Add(object view) { _views.Add(view); return null; } - public IRegionManager Add(VisualElement view, string viewName) + public IRegionManager Add(object view, string viewName) { return Add(view); } - public IRegionManager Add(VisualElement view, string viewName, bool createRegionManagerScope) + public IRegionManager Add(object view, string viewName, bool createRegionManagerScope) { throw new NotImplementedException(); } - public void Remove(VisualElement view) + public void Remove(object view) { throw new NotImplementedException(); } - public void Activate(VisualElement view) + public void Activate(object view) { throw new NotImplementedException(); } - public void Deactivate(VisualElement view) + public void Deactivate(object view) { throw new NotImplementedException(); } - public VisualElement GetView(string viewName) + public object GetView(string viewName) { return GetViewStringDelegate(viewName); } @@ -82,12 +82,12 @@ namespace Prism.Forms.Regions.Mocks } - public void RequestNavigate(Uri target, Action navigationCallback) + public void RequestNavigate(Uri target, Action navigationCallback) { throw new NotImplementedException(); } - public void RequestNavigate(Uri target, Action navigationCallback, INavigationParameters navigationParameters) + public void RequestNavigate(Uri target, Action navigationCallback, INavigationParameters navigationParameters) { throw new NotImplementedException(); } @@ -104,7 +104,7 @@ namespace Prism.Forms.Regions.Mocks } - public Comparison SortComparison + public Comparison SortComparison { get => throw new NotImplementedException(); set => throw new NotImplementedException(); diff --git a/tests/Forms/Prism.Forms.Regions.Tests/Mocks/MockRegionAdapter.cs b/tests/Forms/Prism.Forms.Regions.Tests/Mocks/MockRegionAdapter.cs index 2454fdcf..bb9cc19e 100644 --- a/tests/Forms/Prism.Forms.Regions.Tests/Mocks/MockRegionAdapter.cs +++ b/tests/Forms/Prism.Forms.Regions.Tests/Mocks/MockRegionAdapter.cs @@ -11,14 +11,15 @@ namespace Prism.Forms.Regions.Mocks public MockRegionManagerAccessor Accessor; - public IRegion Initialize(VisualElement regionTarget, string regionName) + public IRegion Initialize(object regionTarget, string regionName) { CreatedRegions.Add(regionName); var region = new MockPresentationRegion(); - Prism.Regions.Xaml.RegionManager.GetObservableRegion(regionTarget).Value = region; + if (regionTarget is VisualElement element) + Prism.Regions.Xaml.RegionManager.GetObservableRegion(element).Value = region; - // Fire update regions again. This also happens if a region is created and added to the regionmanager + // Fire update regions again. This also happens if a region is created and added to the RegionManager if (Accessor != null) Accessor.UpdateRegions(); diff --git a/tests/Forms/Prism.Forms.Regions.Tests/Mocks/MockRegionBehaviorCollection.cs b/tests/Forms/Prism.Forms.Regions.Tests/Mocks/MockRegionBehaviorCollection.cs index 13b12aee..15b1c88a 100644 --- a/tests/Forms/Prism.Forms.Regions.Tests/Mocks/MockRegionBehaviorCollection.cs +++ b/tests/Forms/Prism.Forms.Regions.Tests/Mocks/MockRegionBehaviorCollection.cs @@ -1,6 +1,6 @@ using System.Collections; using System.Collections.Generic; -using Prism.Regions.Behaviors; +using Prism.Regions; namespace Prism.Forms.Regions.Mocks { diff --git a/tests/Forms/Prism.Forms.Regions.Tests/Mocks/MockViewsCollection.cs b/tests/Forms/Prism.Forms.Regions.Tests/Mocks/MockViewsCollection.cs index a72e409b..cb44f685 100644 --- a/tests/Forms/Prism.Forms.Regions.Tests/Mocks/MockViewsCollection.cs +++ b/tests/Forms/Prism.Forms.Regions.Tests/Mocks/MockViewsCollection.cs @@ -9,19 +9,19 @@ namespace Prism.Forms.Regions.Mocks { internal class MockViewsCollection : IViewsCollection { - public ObservableCollection Items = new ObservableCollection(); + public ObservableCollection Items = new ObservableCollection(); - public void Add(VisualElement view) + public void Add(object view) { Items.Add(view); } - public bool Contains(VisualElement value) + public bool Contains(object value) { return Items.Contains(value); } - public IEnumerator GetEnumerator() + public IEnumerator GetEnumerator() { return Items.GetEnumerator(); } diff --git a/tests/Forms/Prism.Forms.Regions.Tests/Tests/LocatorNavigationTargetHandlerFixture.cs b/tests/Forms/Prism.Forms.Regions.Tests/Tests/LocatorNavigationTargetHandlerFixture.cs index 9018e75a..a83b9808 100644 --- a/tests/Forms/Prism.Forms.Regions.Tests/Tests/LocatorNavigationTargetHandlerFixture.cs +++ b/tests/Forms/Prism.Forms.Regions.Tests/Tests/LocatorNavigationTargetHandlerFixture.cs @@ -124,7 +124,7 @@ namespace Prism.Forms.Regions.Tests var viewMock = new Mock(); viewMock .As() - .Setup(v => v.IsNavigationTarget(It.IsAny())) + .Setup(v => v.IsNavigationTarget(It.IsAny())) .Returns(true) .Verifiable(); @@ -157,7 +157,7 @@ namespace Prism.Forms.Regions.Tests var bindingContextMock = new Mock(); bindingContextMock - .Setup(v => v.IsNavigationTarget(It.IsAny())) + .Setup(v => v.IsNavigationTarget(It.IsAny())) .Returns(true) .Verifiable(); var viewMock = new Mock(); @@ -226,7 +226,7 @@ namespace Prism.Forms.Regions.Tests var viewMock = new Mock(); viewMock .As() - .Setup(v => v.IsNavigationTarget(It.IsAny())) + .Setup(v => v.IsNavigationTarget(It.IsAny())) .Returns(false) .Verifiable(); @@ -265,7 +265,7 @@ namespace Prism.Forms.Regions.Tests var bindingContextMock = new Mock(); bindingContextMock - .Setup(v => v.IsNavigationTarget(It.IsAny())) + .Setup(v => v.IsNavigationTarget(It.IsAny())) .Returns(false) .Verifiable(); var viewMock = new Mock(); diff --git a/tests/Forms/Prism.Forms.Regions.Tests/Tests/NavigationAsyncExtensionsFixture.cs b/tests/Forms/Prism.Forms.Regions.Tests/Tests/NavigationAsyncExtensionsFixture.cs index c042d822..dfadb836 100644 --- a/tests/Forms/Prism.Forms.Regions.Tests/Tests/NavigationAsyncExtensionsFixture.cs +++ b/tests/Forms/Prism.Forms.Regions.Tests/Tests/NavigationAsyncExtensionsFixture.cs @@ -2,7 +2,8 @@ using System.Collections.Generic; using System.Text; using Moq; -using Prism.Regions.Navigation; +using Prism.Navigation; +using Prism.Regions; using Xunit; namespace Prism.Forms.Regions.Tests @@ -43,7 +44,7 @@ namespace Prism.Forms.Regions.Tests .Setup(nv => nv.RequestNavigate( It.Is(u => !u.IsAbsoluteUri && u.OriginalString == "relative"), - It.Is>(c => c != null))) + It.Is>(c => c != null))) .Verifiable(); string target = "relative"; @@ -61,7 +62,7 @@ namespace Prism.Forms.Regions.Tests .Setup(nv => nv.RequestNavigate( It.Is(u => u.IsAbsoluteUri && u.Host == "test" && u.AbsolutePath == "/path"), - It.Is>(c => c != null))) + It.Is>(c => c != null))) .Verifiable(); string target = "http://test/path"; @@ -94,7 +95,7 @@ namespace Prism.Forms.Regions.Tests .Setup(nv => nv.RequestNavigate( target, - It.Is>(c => c != null))) + It.Is>(c => c != null))) .Verifiable(); diff --git a/tests/Forms/Prism.Forms.Regions.Tests/Tests/RegionBehaviorCollectionFixture.cs b/tests/Forms/Prism.Forms.Regions.Tests/Tests/RegionBehaviorCollectionFixture.cs index 637d4e85..4823622c 100644 --- a/tests/Forms/Prism.Forms.Regions.Tests/Tests/RegionBehaviorCollectionFixture.cs +++ b/tests/Forms/Prism.Forms.Regions.Tests/Tests/RegionBehaviorCollectionFixture.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Text; using Prism.Forms.Regions.Mocks; -using Prism.Regions.Behaviors; +using Prism.Regions; using Xunit; namespace Prism.Forms.Regions.Tests diff --git a/tests/Forms/Prism.Forms.Regions.Tests/Tests/RegionBehaviorFactoryFixture.cs b/tests/Forms/Prism.Forms.Regions.Tests/Tests/RegionBehaviorFactoryFixture.cs index f68520de..d5ac28bb 100644 --- a/tests/Forms/Prism.Forms.Regions.Tests/Tests/RegionBehaviorFactoryFixture.cs +++ b/tests/Forms/Prism.Forms.Regions.Tests/Tests/RegionBehaviorFactoryFixture.cs @@ -4,7 +4,7 @@ using System.Linq; using Moq; using Prism.Forms.Regions.Mocks; using Prism.Ioc; -using Prism.Regions.Behaviors; +using Prism.Regions; using Xunit; namespace Prism.Forms.Regions.Tests diff --git a/tests/Forms/Prism.Forms.Regions.Tests/Tests/RegionBehaviorFixture.cs b/tests/Forms/Prism.Forms.Regions.Tests/Tests/RegionBehaviorFixture.cs index 653cc0db..1dad2609 100644 --- a/tests/Forms/Prism.Forms.Regions.Tests/Tests/RegionBehaviorFixture.cs +++ b/tests/Forms/Prism.Forms.Regions.Tests/Tests/RegionBehaviorFixture.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Text; using Prism.Forms.Regions.Mocks; +using Prism.Regions; using Prism.Regions.Behaviors; using Xunit; diff --git a/tests/Forms/Prism.Forms.Regions.Tests/Tests/RegionFixture.cs b/tests/Forms/Prism.Forms.Regions.Tests/Tests/RegionFixture.cs index 437ec895..e67c2941 100644 --- a/tests/Forms/Prism.Forms.Regions.Tests/Tests/RegionFixture.cs +++ b/tests/Forms/Prism.Forms.Regions.Tests/Tests/RegionFixture.cs @@ -484,7 +484,7 @@ namespace Prism.Forms.Regions.Tests region.Add(view); var uri = new Uri(view.GetType().Name, UriKind.Relative); - Action navigationCallback = nr => { }; + Action navigationCallback = nr => { }; var navigationParameters = new NavigationParameters(); var mockRegionNavigationService = new Mock(); diff --git a/tests/Forms/Prism.Forms.Regions.Tests/Tests/RegionManagerFixture.cs b/tests/Forms/Prism.Forms.Regions.Tests/Tests/RegionManagerFixture.cs index 58762368..70095001 100644 --- a/tests/Forms/Prism.Forms.Regions.Tests/Tests/RegionManagerFixture.cs +++ b/tests/Forms/Prism.Forms.Regions.Tests/Tests/RegionManagerFixture.cs @@ -479,19 +479,24 @@ namespace Prism.Forms.Regions.Tests internal class MockRegionContentRegistry : IRegionViewRegistry { public Func RegisterContentWithViewType; - public Func, object> RegisterContentWithDelegate; + public Func, object> RegisterContentWithDelegate; public event EventHandler ContentRegistered; - public IEnumerable GetContents(string regionName) + public IEnumerable GetContents(string regionName, IContainerProvider container) { return null; } + public void RegisterViewWithRegion(string regionName, string targetName) + { + throw new NotImplementedException(); + } + void IRegionViewRegistry.RegisterViewWithRegion(string regionName, Type viewType) { RegisterContentWithViewType?.Invoke(regionName, viewType); } - void IRegionViewRegistry.RegisterViewWithRegion(string regionName, Func getContentDelegate) + void IRegionViewRegistry.RegisterViewWithRegion(string regionName, Func getContentDelegate) { RegisterContentWithDelegate?.Invoke(regionName, getContentDelegate); diff --git a/tests/Forms/Prism.Forms.Regions.Tests/Tests/RegionManagerRequestNavigateFixture.cs b/tests/Forms/Prism.Forms.Regions.Tests/Tests/RegionManagerRequestNavigateFixture.cs index 1ca5791d..925519d8 100644 --- a/tests/Forms/Prism.Forms.Regions.Tests/Tests/RegionManagerRequestNavigateFixture.cs +++ b/tests/Forms/Prism.Forms.Regions.Tests/Tests/RegionManagerRequestNavigateFixture.cs @@ -17,7 +17,7 @@ namespace Prism.Forms.Regions.Tests private static Uri sourceUri = new Uri(source, UriKind.RelativeOrAbsolute); private static INavigationParameters parameters = new NavigationParameters(); - private static Action callback = (_) => { }; + private static Action callback = (_) => { }; private static Mock mockRegion; private static Mock mockNavigation; @@ -53,51 +53,51 @@ namespace Prism.Forms.Regions.Tests [Fact] public void WhenNonExistentRegion_ReturnNavigationResultFalse() { - IRegionNavigationResult result; + NavigationResult result; result = null; regionManager.RequestNavigate(nonExistentRegion, source, (r) => result = r, parameters); - Assert.Equal(false, result.Result); + Assert.False(result.Success); result = null; regionManager.RequestNavigate(nonExistentRegion, source, (r) => result = r); - Assert.Equal(false, result.Result); + Assert.False(result.Success); result = null; regionManager.RequestNavigate(nonExistentRegion, sourceUri, (r) => result = r, parameters); - Assert.Equal(false, result.Result); + Assert.False(result.Success); result = null; regionManager.RequestNavigate(nonExistentRegion, sourceUri, (r) => result = r); - Assert.Equal(false, result.Result); + Assert.False(result.Success); } [Fact] public void DelegatesCallToRegion_RegionSource() { regionManager.RequestNavigate(region, source); - mockNavigation.Verify((r) => r.RequestNavigate(sourceUri, It.IsAny>(), null)); + mockNavigation.Verify((r) => r.RequestNavigate(sourceUri, It.IsAny>(), null)); } [Fact] public void DelegatesCallToRegion_RegionTarget() { regionManager.RequestNavigate(region, sourceUri); - mockNavigation.Verify((r) => r.RequestNavigate(sourceUri, It.IsAny>(), null)); + mockNavigation.Verify((r) => r.RequestNavigate(sourceUri, It.IsAny>(), null)); } [Fact] public void DelegatesCallToRegion_RegionSourceParameters() { regionManager.RequestNavigate(region, source, parameters); - mockRegion.Verify((r) => r.NavigationService.RequestNavigate(sourceUri, It.IsAny>(), parameters)); + mockRegion.Verify((r) => r.NavigationService.RequestNavigate(sourceUri, It.IsAny>(), parameters)); } [Fact] public void DelegatesCallToRegion_RegionSourceUriParameters() { regionManager.RequestNavigate(region, sourceUri, parameters); - mockRegion.Verify((r) => r.NavigationService.RequestNavigate(sourceUri, It.IsAny>(), parameters)); + mockRegion.Verify((r) => r.NavigationService.RequestNavigate(sourceUri, It.IsAny>(), parameters)); } [Fact] diff --git a/tests/Forms/Prism.Forms.Regions.Tests/Tests/RegionNavigationJournalFixture.cs b/tests/Forms/Prism.Forms.Regions.Tests/Tests/RegionNavigationJournalFixture.cs index c500b879..a444489d 100644 --- a/tests/Forms/Prism.Forms.Regions.Tests/Tests/RegionNavigationJournalFixture.cs +++ b/tests/Forms/Prism.Forms.Regions.Tests/Tests/RegionNavigationJournalFixture.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Text; using Moq; using Prism.Navigation; +using Prism.Regions; using Prism.Regions.Navigation; using Xunit; @@ -134,14 +135,14 @@ namespace Prism.Forms.Regions.Tests mockNavigationTarget - .Setup(x => x.RequestNavigate(uri1, It.IsAny>(), null)) - .Callback, INavigationParameters>((u, c, n) => c(new RegionNavigationResult(null, true))); + .Setup(x => x.RequestNavigate(uri1, It.IsAny>(), null)) + .Callback, INavigationParameters>((u, c, n) => c(new NavigationResult(null, true))); mockNavigationTarget - .Setup(x => x.RequestNavigate(uri2, It.IsAny>(), null)) - .Callback, INavigationParameters>((u, c, n) => c(new RegionNavigationResult(null, true))); + .Setup(x => x.RequestNavigate(uri2, It.IsAny>(), null)) + .Callback, INavigationParameters>((u, c, n) => c(new NavigationResult(null, true))); mockNavigationTarget - .Setup(x => x.RequestNavigate(uri3, It.IsAny>(), null)) - .Callback, INavigationParameters>((u, c, n) => c(new RegionNavigationResult(null, true))); + .Setup(x => x.RequestNavigate(uri3, It.IsAny>(), null)) + .Callback, INavigationParameters>((u, c, n) => c(new NavigationResult(null, true))); // Act target.GoBack(); @@ -151,9 +152,9 @@ namespace Prism.Forms.Regions.Tests Assert.True(target.CanGoForward); Assert.Same(entry2, target.CurrentEntry); - mockNavigationTarget.Verify(x => x.RequestNavigate(uri1, It.IsAny>(), null), Times.Never()); - mockNavigationTarget.Verify(x => x.RequestNavigate(uri2, It.IsAny>(), null), Times.Once()); - mockNavigationTarget.Verify(x => x.RequestNavigate(uri3, It.IsAny>(), null), Times.Never()); + mockNavigationTarget.Verify(x => x.RequestNavigate(uri1, It.IsAny>(), null), Times.Never()); + mockNavigationTarget.Verify(x => x.RequestNavigate(uri2, It.IsAny>(), null), Times.Once()); + mockNavigationTarget.Verify(x => x.RequestNavigate(uri3, It.IsAny>(), null), Times.Never()); } [Fact] @@ -180,14 +181,14 @@ namespace Prism.Forms.Regions.Tests mockNavigationTarget - .Setup(x => x.RequestNavigate(uri1, It.IsAny>(), null)) - .Callback, INavigationParameters>((u, c, n) => c(new RegionNavigationResult(null, true))); + .Setup(x => x.RequestNavigate(uri1, It.IsAny>(), null)) + .Callback, INavigationParameters>((u, c, n) => c(new NavigationResult(null, true))); mockNavigationTarget - .Setup(x => x.RequestNavigate(uri2, It.IsAny>(), null)) - .Callback, INavigationParameters>((u, c, n) => c(new RegionNavigationResult(null, false))); + .Setup(x => x.RequestNavigate(uri2, It.IsAny>(), null)) + .Callback, INavigationParameters>((u, c, n) => c(new NavigationResult(null, false))); mockNavigationTarget - .Setup(x => x.RequestNavigate(uri3, It.IsAny>(), null)) - .Callback, INavigationParameters>((u, c, n) => c(new RegionNavigationResult(null, true))); + .Setup(x => x.RequestNavigate(uri3, It.IsAny>(), null)) + .Callback, INavigationParameters>((u, c, n) => c(new NavigationResult(null, true))); // Act target.GoBack(); @@ -197,9 +198,9 @@ namespace Prism.Forms.Regions.Tests Assert.False(target.CanGoForward); Assert.Same(entry3, target.CurrentEntry); - mockNavigationTarget.Verify(x => x.RequestNavigate(uri1, It.IsAny>(), null), Times.Never()); - mockNavigationTarget.Verify(x => x.RequestNavigate(uri2, It.IsAny>(), null), Times.Once()); - mockNavigationTarget.Verify(x => x.RequestNavigate(uri3, It.IsAny>(), null), Times.Never()); + mockNavigationTarget.Verify(x => x.RequestNavigate(uri1, It.IsAny>(), null), Times.Never()); + mockNavigationTarget.Verify(x => x.RequestNavigate(uri2, It.IsAny>(), null), Times.Once()); + mockNavigationTarget.Verify(x => x.RequestNavigate(uri3, It.IsAny>(), null), Times.Never()); } [Fact] @@ -226,14 +227,14 @@ namespace Prism.Forms.Regions.Tests mockNavigationTarget - .Setup(x => x.RequestNavigate(uri1, It.IsAny>(), null)) - .Callback, INavigationParameters>((u, c, n) => c(new RegionNavigationResult(null, true))); + .Setup(x => x.RequestNavigate(uri1, It.IsAny>(), null)) + .Callback, INavigationParameters>((u, c, n) => c(new NavigationResult(null, true))); mockNavigationTarget - .Setup(x => x.RequestNavigate(uri2, It.IsAny>(), null)) - .Callback, INavigationParameters>((u, c, n) => c(new RegionNavigationResult(null, true))); + .Setup(x => x.RequestNavigate(uri2, It.IsAny>(), null)) + .Callback, INavigationParameters>((u, c, n) => c(new NavigationResult(null, true))); mockNavigationTarget - .Setup(x => x.RequestNavigate(uri3, It.IsAny>(), null)) - .Callback, INavigationParameters>((u, c, n) => c(new RegionNavigationResult(null, true))); + .Setup(x => x.RequestNavigate(uri3, It.IsAny>(), null)) + .Callback, INavigationParameters>((u, c, n) => c(new NavigationResult(null, true))); // Act target.GoBack(); @@ -244,9 +245,9 @@ namespace Prism.Forms.Regions.Tests Assert.True(target.CanGoForward); Assert.Same(entry1, target.CurrentEntry); - mockNavigationTarget.Verify(x => x.RequestNavigate(uri1, It.IsAny>(), null), Times.Once()); - mockNavigationTarget.Verify(x => x.RequestNavigate(uri2, It.IsAny>(), null), Times.Once()); - mockNavigationTarget.Verify(x => x.RequestNavigate(uri3, It.IsAny>(), null), Times.Never()); + mockNavigationTarget.Verify(x => x.RequestNavigate(uri1, It.IsAny>(), null), Times.Once()); + mockNavigationTarget.Verify(x => x.RequestNavigate(uri2, It.IsAny>(), null), Times.Once()); + mockNavigationTarget.Verify(x => x.RequestNavigate(uri3, It.IsAny>(), null), Times.Never()); } [Fact] @@ -272,14 +273,14 @@ namespace Prism.Forms.Regions.Tests target.RecordNavigation(entry3, true); mockNavigationTarget - .Setup(x => x.RequestNavigate(uri1, It.IsAny>(), null)) - .Callback, INavigationParameters>((u, c, n) => c(new RegionNavigationResult(null, true))); + .Setup(x => x.RequestNavigate(uri1, It.IsAny>(), null)) + .Callback, INavigationParameters>((u, c, n) => c(new NavigationResult(null, true))); mockNavigationTarget - .Setup(x => x.RequestNavigate(uri2, It.IsAny>(), null)) - .Callback, INavigationParameters>((u, c, n) => c(new RegionNavigationResult(null, true))); + .Setup(x => x.RequestNavigate(uri2, It.IsAny>(), null)) + .Callback, INavigationParameters>((u, c, n) => c(new NavigationResult(null, true))); mockNavigationTarget - .Setup(x => x.RequestNavigate(uri3, It.IsAny>(), null)) - .Callback, INavigationParameters>((u, c, n) => c(new RegionNavigationResult(null, true))); + .Setup(x => x.RequestNavigate(uri3, It.IsAny>(), null)) + .Callback, INavigationParameters>((u, c, n) => c(new NavigationResult(null, true))); target.GoBack(); target.GoBack(); @@ -292,9 +293,9 @@ namespace Prism.Forms.Regions.Tests Assert.True(target.CanGoForward); Assert.Same(entry2, target.CurrentEntry); - mockNavigationTarget.Verify(x => x.RequestNavigate(uri1, It.IsAny>(), null), Times.Once()); - mockNavigationTarget.Verify(x => x.RequestNavigate(uri2, It.IsAny>(), null), Times.Exactly(2)); - mockNavigationTarget.Verify(x => x.RequestNavigate(uri3, It.IsAny>(), null), Times.Never()); + mockNavigationTarget.Verify(x => x.RequestNavigate(uri1, It.IsAny>(), null), Times.Once()); + mockNavigationTarget.Verify(x => x.RequestNavigate(uri2, It.IsAny>(), null), Times.Exactly(2)); + mockNavigationTarget.Verify(x => x.RequestNavigate(uri3, It.IsAny>(), null), Times.Never()); } [Fact] @@ -320,14 +321,14 @@ namespace Prism.Forms.Regions.Tests target.RecordNavigation(entry3, true); mockNavigationTarget - .Setup(x => x.RequestNavigate(uri1, It.IsAny>(), null)) - .Callback, INavigationParameters>((u, c, n) => c(new RegionNavigationResult(null, true))); + .Setup(x => x.RequestNavigate(uri1, It.IsAny>(), null)) + .Callback, INavigationParameters>((u, c, n) => c(new NavigationResult(null, true))); mockNavigationTarget - .Setup(x => x.RequestNavigate(uri2, It.IsAny>(), null)) - .Callback, INavigationParameters>((u, c, n) => c(new RegionNavigationResult(null, true))); + .Setup(x => x.RequestNavigate(uri2, It.IsAny>(), null)) + .Callback, INavigationParameters>((u, c, n) => c(new NavigationResult(null, true))); mockNavigationTarget - .Setup(x => x.RequestNavigate(uri3, It.IsAny>(), null)) - .Callback, INavigationParameters>((u, c, n) => c(new RegionNavigationResult(null, false))); + .Setup(x => x.RequestNavigate(uri3, It.IsAny>(), null)) + .Callback, INavigationParameters>((u, c, n) => c(new NavigationResult(null, false))); target.GoBack(); @@ -339,9 +340,9 @@ namespace Prism.Forms.Regions.Tests Assert.True(target.CanGoForward); Assert.Same(entry2, target.CurrentEntry); - mockNavigationTarget.Verify(x => x.RequestNavigate(uri1, It.IsAny>(), null), Times.Never()); - mockNavigationTarget.Verify(x => x.RequestNavigate(uri2, It.IsAny>(), null), Times.Once()); - mockNavigationTarget.Verify(x => x.RequestNavigate(uri3, It.IsAny>(), null), Times.Once()); + mockNavigationTarget.Verify(x => x.RequestNavigate(uri1, It.IsAny>(), null), Times.Never()); + mockNavigationTarget.Verify(x => x.RequestNavigate(uri2, It.IsAny>(), null), Times.Once()); + mockNavigationTarget.Verify(x => x.RequestNavigate(uri3, It.IsAny>(), null), Times.Once()); } [Fact] @@ -367,14 +368,14 @@ namespace Prism.Forms.Regions.Tests target.RecordNavigation(entry3, true); mockNavigationTarget - .Setup(x => x.RequestNavigate(uri1, It.IsAny>(), null)) - .Callback, INavigationParameters>((u, c, n) => c(new RegionNavigationResult(null, true))); + .Setup(x => x.RequestNavigate(uri1, It.IsAny>(), null)) + .Callback, INavigationParameters>((u, c, n) => c(new NavigationResult(null, true))); mockNavigationTarget - .Setup(x => x.RequestNavigate(uri2, It.IsAny>(), null)) - .Callback, INavigationParameters>((u, c, n) => c(new RegionNavigationResult(null, true))); + .Setup(x => x.RequestNavigate(uri2, It.IsAny>(), null)) + .Callback, INavigationParameters>((u, c, n) => c(new NavigationResult(null, true))); mockNavigationTarget - .Setup(x => x.RequestNavigate(uri3, It.IsAny>(), null)) - .Callback, INavigationParameters>((u, c, n) => c(new RegionNavigationResult(null, true))); + .Setup(x => x.RequestNavigate(uri3, It.IsAny>(), null)) + .Callback, INavigationParameters>((u, c, n) => c(new NavigationResult(null, true))); target.GoBack(); target.GoBack(); @@ -388,9 +389,9 @@ namespace Prism.Forms.Regions.Tests Assert.False(target.CanGoForward); Assert.Same(entry3, target.CurrentEntry); - mockNavigationTarget.Verify(x => x.RequestNavigate(uri1, It.IsAny>(), null), Times.Once()); - mockNavigationTarget.Verify(x => x.RequestNavigate(uri2, It.IsAny>(), null), Times.Exactly(2)); - mockNavigationTarget.Verify(x => x.RequestNavigate(uri3, It.IsAny>(), null), Times.Once()); + mockNavigationTarget.Verify(x => x.RequestNavigate(uri1, It.IsAny>(), null), Times.Once()); + mockNavigationTarget.Verify(x => x.RequestNavigate(uri2, It.IsAny>(), null), Times.Exactly(2)); + mockNavigationTarget.Verify(x => x.RequestNavigate(uri3, It.IsAny>(), null), Times.Once()); } [Fact] @@ -418,14 +419,14 @@ namespace Prism.Forms.Regions.Tests target.RecordNavigation(entry2, true); mockNavigationTarget - .Setup(x => x.RequestNavigate(uri1, It.IsAny>(), null)) - .Callback, INavigationParameters>((u, c, n) => c(new RegionNavigationResult(null, true))); + .Setup(x => x.RequestNavigate(uri1, It.IsAny>(), null)) + .Callback, INavigationParameters>((u, c, n) => c(new NavigationResult(null, true))); mockNavigationTarget - .Setup(x => x.RequestNavigate(uri2, It.IsAny>(), null)) - .Callback, INavigationParameters>((u, c, n) => c(new RegionNavigationResult(null, true))); + .Setup(x => x.RequestNavigate(uri2, It.IsAny>(), null)) + .Callback, INavigationParameters>((u, c, n) => c(new NavigationResult(null, true))); mockNavigationTarget - .Setup(x => x.RequestNavigate(uri3, It.IsAny>(), null)) - .Callback, INavigationParameters>((u, c, n) => c(new RegionNavigationResult(null, true))); + .Setup(x => x.RequestNavigate(uri3, It.IsAny>(), null)) + .Callback, INavigationParameters>((u, c, n) => c(new NavigationResult(null, true))); target.GoBack(); @@ -466,17 +467,17 @@ namespace Prism.Forms.Regions.Tests target.RecordNavigation(entry4, true); mockNavigationTarget - .Setup(x => x.RequestNavigate(uri1, It.IsAny>(), null)) - .Callback, INavigationParameters>((u, c, n) => c(new RegionNavigationResult(null, true))); + .Setup(x => x.RequestNavigate(uri1, It.IsAny>(), null)) + .Callback, INavigationParameters>((u, c, n) => c(new NavigationResult(null, true))); mockNavigationTarget - .Setup(x => x.RequestNavigate(uri2, It.IsAny>(), null)) - .Callback, INavigationParameters>((u, c, n) => c(new RegionNavigationResult(null, true))); + .Setup(x => x.RequestNavigate(uri2, It.IsAny>(), null)) + .Callback, INavigationParameters>((u, c, n) => c(new NavigationResult(null, true))); mockNavigationTarget - .Setup(x => x.RequestNavigate(uri3, It.IsAny>(), null)) - .Callback, INavigationParameters>((u, c, n) => c(new RegionNavigationResult(null, true))); + .Setup(x => x.RequestNavigate(uri3, It.IsAny>(), null)) + .Callback, INavigationParameters>((u, c, n) => c(new NavigationResult(null, true))); mockNavigationTarget - .Setup(x => x.RequestNavigate(uri4, It.IsAny>(), null)) - .Callback, INavigationParameters>((u, c, n) => c(new RegionNavigationResult(null, true))); + .Setup(x => x.RequestNavigate(uri4, It.IsAny>(), null)) + .Callback, INavigationParameters>((u, c, n) => c(new NavigationResult(null, true))); Assert.Equal(entry4, target.CurrentEntry); @@ -486,10 +487,10 @@ namespace Prism.Forms.Regions.Tests Assert.True(target.CanGoForward); Assert.Same(entry2, target.CurrentEntry); - mockNavigationTarget.Verify(x => x.RequestNavigate(uri1, It.IsAny>(), null), Times.Never()); - mockNavigationTarget.Verify(x => x.RequestNavigate(uri2, It.IsAny>(), null), Times.Once()); - mockNavigationTarget.Verify(x => x.RequestNavigate(uri3, It.IsAny>(), null), Times.Never()); - mockNavigationTarget.Verify(x => x.RequestNavigate(uri4, It.IsAny>(), null), Times.Never()); + mockNavigationTarget.Verify(x => x.RequestNavigate(uri1, It.IsAny>(), null), Times.Never()); + mockNavigationTarget.Verify(x => x.RequestNavigate(uri2, It.IsAny>(), null), Times.Once()); + mockNavigationTarget.Verify(x => x.RequestNavigate(uri3, It.IsAny>(), null), Times.Never()); + mockNavigationTarget.Verify(x => x.RequestNavigate(uri4, It.IsAny>(), null), Times.Never()); } } } diff --git a/tests/Forms/Prism.Forms.Regions.Tests/Tests/RegionNavigationServiceFixture.cs b/tests/Forms/Prism.Forms.Regions.Tests/Tests/RegionNavigationServiceFixture.cs index d9ed4548..afdcaea5 100644 --- a/tests/Forms/Prism.Forms.Regions.Tests/Tests/RegionNavigationServiceFixture.cs +++ b/tests/Forms/Prism.Forms.Regions.Tests/Tests/RegionNavigationServiceFixture.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using Moq; using Prism.Ioc; +using Prism.Navigation; using Prism.Regions; using Prism.Regions.Navigation; using Xamarin.Forms; @@ -41,7 +42,7 @@ namespace Prism.Forms.Regions.Tests // Act bool isNavigationSuccessful = false; - target.RequestNavigate(viewUri, nr => isNavigationSuccessful = nr.Result == true); + target.RequestNavigate(viewUri, nr => isNavigationSuccessful = nr.Success == true); // Verify Assert.True(isNavigationSuccessful); @@ -77,7 +78,7 @@ namespace Prism.Forms.Regions.Tests // Act bool isNavigationSuccessful = false; - target.RequestNavigate(viewUri, nr => isNavigationSuccessful = nr.Result == true); + target.RequestNavigate(viewUri, nr => isNavigationSuccessful = nr.Success == true); // Verify Assert.True(isNavigationSuccessful); @@ -102,7 +103,7 @@ namespace Prism.Forms.Regions.Tests IContainerExtension container = containerMock.Object; var targetHandlerMock = new Mock(); - targetHandlerMock.Setup(th => th.LoadContent(It.IsAny(), It.IsAny())).Throws(); + targetHandlerMock.Setup(th => th.LoadContent(It.IsAny(), It.IsAny())).Throws(); IRegionNavigationJournal journal = Mock.Of(); @@ -117,7 +118,7 @@ namespace Prism.Forms.Regions.Tests new Uri(otherType.GetType().Name, UriKind.Relative), nr => { - error = nr.Error; + error = nr.Exception; }); // Verify @@ -145,13 +146,13 @@ namespace Prism.Forms.Regions.Tests }; // Act - IRegionNavigationResult navigationResult = null; + NavigationResult navigationResult = null; target.RequestNavigate((Uri)null, nr => navigationResult = nr); // Verify - Assert.False(navigationResult.Result.Value); - Assert.NotNull(navigationResult.Error); - Assert.IsType(navigationResult.Error); + Assert.False(navigationResult.Success); + Assert.NotNull(navigationResult.Exception); + Assert.IsType(navigationResult.Exception); } [Fact] @@ -163,7 +164,7 @@ namespace Prism.Forms.Regions.Tests var viewMock = new Mock(); viewMock .As() - .Setup(ina => ina.IsNavigationTarget(It.IsAny())) + .Setup(ina => ina.IsNavigationTarget(It.IsAny())) .Returns(true); var view = viewMock.Object; region.Add(view); @@ -188,7 +189,7 @@ namespace Prism.Forms.Regions.Tests // Verify viewMock .As() - .Verify(v => v.OnNavigatedTo(It.Is(nc => nc.Uri == navigationUri && nc.NavigationService == target))); + .Verify(v => v.OnNavigatedTo(It.Is(nc => nc.Uri == navigationUri && nc.NavigationService == target))); } [Fact] @@ -200,7 +201,7 @@ namespace Prism.Forms.Regions.Tests var mockView = new Mock(); var mockIRegionAwareBindingContext = new Mock(); mockIRegionAwareBindingContext - .Setup(ina => ina.IsNavigationTarget(It.IsAny())) + .Setup(ina => ina.IsNavigationTarget(It.IsAny())) .Returns(true); mockView.Object.BindingContext = mockIRegionAwareBindingContext.Object; @@ -225,7 +226,7 @@ namespace Prism.Forms.Regions.Tests target.RequestNavigate(navigationUri, nr => { }); // Verify - mockIRegionAwareBindingContext.Verify(v => v.OnNavigatedTo(It.Is(nc => nc.Uri == navigationUri))); + mockIRegionAwareBindingContext.Verify(v => v.OnNavigatedTo(It.Is(nc => nc.Uri == navigationUri))); } [Fact] @@ -237,11 +238,11 @@ namespace Prism.Forms.Regions.Tests var mockView = new Mock(); var mockIRegionAwareView = mockView.As(); mockIRegionAwareView - .Setup(ina => ina.IsNavigationTarget(It.IsAny())) + .Setup(ina => ina.IsNavigationTarget(It.IsAny())) .Returns(true); var mockIRegionAwareBindingContext = new Mock(); - mockIRegionAwareBindingContext.Setup(ina => ina.IsNavigationTarget(It.IsAny())).Returns(true); + mockIRegionAwareBindingContext.Setup(ina => ina.IsNavigationTarget(It.IsAny())).Returns(true); mockView.Object.BindingContext = mockIRegionAwareBindingContext.Object; var view = mockView.Object; @@ -265,8 +266,8 @@ namespace Prism.Forms.Regions.Tests target.RequestNavigate(navigationUri, nr => { }); // Verify - mockIRegionAwareView.Verify(v => v.OnNavigatedTo(It.Is(nc => nc.Uri == navigationUri))); - mockIRegionAwareBindingContext.Verify(v => v.OnNavigatedTo(It.Is(nc => nc.Uri == navigationUri))); + mockIRegionAwareView.Verify(v => v.OnNavigatedTo(It.Is(nc => nc.Uri == navigationUri))); + mockIRegionAwareBindingContext.Verify(v => v.OnNavigatedTo(It.Is(nc => nc.Uri == navigationUri))); } [Fact] @@ -319,8 +320,8 @@ namespace Prism.Forms.Regions.Tests var viewMock = new Mock(); viewMock - .As() - .Setup(ina => ina.ConfirmNavigationRequest(It.IsAny(), It.IsAny>())) + .As() + .Setup(ina => ina.ConfirmNavigationRequest(It.IsAny(), It.IsAny>())) .Verifiable(); var view = viewMock.Object; @@ -356,9 +357,9 @@ namespace Prism.Forms.Regions.Tests var view1Mock = new Mock(); view1Mock - .As() - .Setup(ina => ina.ConfirmNavigationRequest(It.IsAny(), It.IsAny>())) - .Callback>((nc, c) => c(true)) + .As() + .Setup(ina => ina.ConfirmNavigationRequest(It.IsAny(), It.IsAny>())) + .Callback>((nc, c) => c(true)) .Verifiable(); var view1 = view1Mock.Object; @@ -366,7 +367,7 @@ namespace Prism.Forms.Regions.Tests region.Activate(view1); var view2Mock = new Mock(); - view2Mock.As(); + view2Mock.As(); var view2 = view2Mock.Object; region.Add(view2); @@ -380,9 +381,9 @@ namespace Prism.Forms.Regions.Tests var view4Mock = new Mock(); view4Mock - .As() - .Setup(ina => ina.ConfirmNavigationRequest(It.IsAny(), It.IsAny>())) - .Callback>((nc, c) => c(true)) + .As() + .Setup(ina => ina.ConfirmNavigationRequest(It.IsAny(), It.IsAny>())) + .Callback>((nc, c) => c(true)) .Verifiable(); var view4 = view4Mock.Object; @@ -409,8 +410,8 @@ namespace Prism.Forms.Regions.Tests // Verify view1Mock.VerifyAll(); view2Mock - .As() - .Verify(ina => ina.ConfirmNavigationRequest(It.IsAny(), It.IsAny>()), Times.Never()); + .As() + .Verify(ina => ina.ConfirmNavigationRequest(It.IsAny(), It.IsAny>()), Times.Never()); view3Mock.VerifyAll(); view4Mock.VerifyAll(); } @@ -423,9 +424,9 @@ namespace Prism.Forms.Regions.Tests var view1Mock = new Mock(); view1Mock - .As() - .Setup(ina => ina.ConfirmNavigationRequest(It.IsAny(), It.IsAny>())) - .Callback>((nc, c) => c(true)) + .As() + .Setup(ina => ina.ConfirmNavigationRequest(It.IsAny(), It.IsAny>())) + .Callback>((nc, c) => c(true)) .Verifiable(); var view1 = view1Mock.Object; @@ -453,7 +454,7 @@ namespace Prism.Forms.Regions.Tests // Act var navigationSucceeded = false; - target.RequestNavigate(navigationUri, nr => { navigationSucceeded = nr.Result == true; }); + target.RequestNavigate(navigationUri, nr => { navigationSucceeded = nr.Success == true; }); // Verify view1Mock.VerifyAll(); @@ -469,9 +470,9 @@ namespace Prism.Forms.Regions.Tests var view1Mock = new Mock(); view1Mock - .As() - .Setup(ina => ina.ConfirmNavigationRequest(It.IsAny(), It.IsAny>())) - .Callback>((nc, c) => c(false)) + .As() + .Setup(ina => ina.ConfirmNavigationRequest(It.IsAny(), It.IsAny>())) + .Callback>((nc, c) => c(false)) .Verifiable(); var view1 = view1Mock.Object; @@ -499,7 +500,7 @@ namespace Prism.Forms.Regions.Tests // Act var navigationFailed = false; - target.RequestNavigate(navigationUri, nr => { navigationFailed = nr.Result == false; }); + target.RequestNavigate(navigationUri, nr => { navigationFailed = nr.Success == false; }); // Verify view1Mock.VerifyAll(); @@ -513,9 +514,9 @@ namespace Prism.Forms.Regions.Tests // Prepare var region = new Region(); - var viewModelMock = new Mock(); + var viewModelMock = new Mock(); viewModelMock - .Setup(ina => ina.ConfirmNavigationRequest(It.IsAny(), It.IsAny>())) + .Setup(ina => ina.ConfirmNavigationRequest(It.IsAny(), It.IsAny>())) .Verifiable(); var viewMock = new Mock(); @@ -553,10 +554,10 @@ namespace Prism.Forms.Regions.Tests // Prepare var region = new Region(); - var view1BindingContextMock = new Mock(); + var view1BindingContextMock = new Mock(); view1BindingContextMock - .Setup(ina => ina.ConfirmNavigationRequest(It.IsAny(), It.IsAny>())) - .Callback>((nc, c) => c(true)) + .Setup(ina => ina.ConfirmNavigationRequest(It.IsAny(), It.IsAny>())) + .Callback>((nc, c) => c(true)) .Verifiable(); var view1Mock = new Mock(); @@ -586,7 +587,7 @@ namespace Prism.Forms.Regions.Tests // Act var navigationSucceeded = false; - target.RequestNavigate(navigationUri, nr => { navigationSucceeded = nr.Result == true; }); + target.RequestNavigate(navigationUri, nr => { navigationSucceeded = nr.Success == true; }); // Verify view1BindingContextMock.VerifyAll(); @@ -600,10 +601,10 @@ namespace Prism.Forms.Regions.Tests // Prepare var region = new Region(); - var view1BindingContextMock = new Mock(); + var view1BindingContextMock = new Mock(); view1BindingContextMock - .Setup(ina => ina.ConfirmNavigationRequest(It.IsAny(), It.IsAny>())) - .Callback>((nc, c) => c(false)) + .Setup(ina => ina.ConfirmNavigationRequest(It.IsAny(), It.IsAny>())) + .Callback>((nc, c) => c(false)) .Verifiable(); var view1Mock = new Mock(); @@ -633,7 +634,7 @@ namespace Prism.Forms.Regions.Tests // Act var navigationFailed = false; - target.RequestNavigate(navigationUri, nr => { navigationFailed = nr.Result == false; }); + target.RequestNavigate(navigationUri, nr => { navigationFailed = nr.Success == false; }); // Verify view1BindingContextMock.VerifyAll(); @@ -651,9 +652,9 @@ namespace Prism.Forms.Regions.Tests var confirmationRequests = new List>(); viewMock - .As() - .Setup(icnr => icnr.ConfirmNavigationRequest(It.IsAny(), It.IsAny>())) - .Callback>((nc, c) => { confirmationRequests.Add(c); }); + .As() + .Setup(icnr => icnr.ConfirmNavigationRequest(It.IsAny(), It.IsAny>())) + .Callback>((nc, c) => { confirmationRequests.Add(c); }); var view = viewMock.Object; region.Add(view); @@ -668,7 +669,7 @@ namespace Prism.Forms.Regions.Tests var contentLoaderMock = new Mock(); contentLoaderMock - .Setup(cl => cl.LoadContent(region, It.IsAny())) + .Setup(cl => cl.LoadContent(region, It.IsAny())) .Returns(view); var container = containerMock.Object; @@ -682,8 +683,8 @@ namespace Prism.Forms.Regions.Tests bool firstNavigation = false; bool secondNavigation = false; - target.RequestNavigate(navigationUri, nr => firstNavigation = nr.Result.Value); - target.RequestNavigate(navigationUri, nr => secondNavigation = nr.Result.Value); + target.RequestNavigate(navigationUri, nr => firstNavigation = nr.Success); + target.RequestNavigate(navigationUri, nr => secondNavigation = nr.Success); Assert.Equal(2, confirmationRequests.Count); @@ -699,7 +700,7 @@ namespace Prism.Forms.Regions.Tests { var region = new Region(); - var viewModelMock = new Mock(); + var viewModelMock = new Mock(); var viewMock = new Mock(); var view = viewMock.Object; @@ -708,8 +709,8 @@ namespace Prism.Forms.Regions.Tests var confirmationRequests = new List>(); viewModelMock - .Setup(icnr => icnr.ConfirmNavigationRequest(It.IsAny(), It.IsAny>())) - .Callback>((nc, c) => { confirmationRequests.Add(c); }); + .Setup(icnr => icnr.ConfirmNavigationRequest(It.IsAny(), It.IsAny>())) + .Callback>((nc, c) => { confirmationRequests.Add(c); }); region.Add(view); region.Activate(view); @@ -723,7 +724,7 @@ namespace Prism.Forms.Regions.Tests var contentLoaderMock = new Mock(); contentLoaderMock - .Setup(cl => cl.LoadContent(region, It.IsAny())) + .Setup(cl => cl.LoadContent(region, It.IsAny())) .Returns(view); var container = containerMock.Object; @@ -735,8 +736,8 @@ namespace Prism.Forms.Regions.Tests Region = region }; - IRegionNavigationResult firstNavigation = null; - IRegionNavigationResult secondNavigation = null; + NavigationResult firstNavigation = null; + NavigationResult secondNavigation = null; target.RequestNavigate(navigationUri, nr => firstNavigation = nr); target.RequestNavigate(navigationUri, nr => secondNavigation = nr); @@ -745,8 +746,8 @@ namespace Prism.Forms.Regions.Tests confirmationRequests[0](true); confirmationRequests[1](true); - Assert.False(firstNavigation.Result); - Assert.True(secondNavigation.Result.Value); + Assert.False(firstNavigation.Success); + Assert.True(secondNavigation.Success); } [Fact] @@ -786,7 +787,7 @@ namespace Prism.Forms.Regions.Tests // Act bool isNavigationSuccessful = false; - target.RequestNavigate(viewUri, nr => isNavigationSuccessful = nr.Result == true); + target.RequestNavigate(viewUri, nr => isNavigationSuccessful = nr.Success == true); // Verify Assert.True(isNavigationSuccessful); @@ -830,7 +831,7 @@ namespace Prism.Forms.Regions.Tests // Act bool isNavigationSuccessful = false; - target.RequestNavigate(viewUri, nr => isNavigationSuccessful = nr.Result == true); + target.RequestNavigate(viewUri, nr => isNavigationSuccessful = nr.Success == true); // Verify Assert.True(isNavigationSuccessful); @@ -845,7 +846,7 @@ namespace Prism.Forms.Regions.Tests var targetException = new Exception(); var targetHandlerMock = new Mock(); targetHandlerMock - .Setup(th => th.LoadContent(It.IsAny(), It.IsAny())) + .Setup(th => th.LoadContent(It.IsAny(), It.IsAny())) .Throws(targetException); var journalMock = new Mock(); @@ -853,9 +854,9 @@ namespace Prism.Forms.Regions.Tests Action navigationCallback = null; var viewMock = new Mock(); viewMock - .As() - .Setup(v => v.ConfirmNavigationRequest(It.IsAny(), It.IsAny>())) - .Callback>((nc, c) => { navigationCallback = c; }); + .As() + .Setup(v => v.ConfirmNavigationRequest(It.IsAny(), It.IsAny>())) + .Callback>((nc, c) => { navigationCallback = c; }); var region = new Region(); region.Add(viewMock.Object); @@ -866,12 +867,12 @@ namespace Prism.Forms.Regions.Tests Region = region }; - IRegionNavigationResult result = null; + NavigationResult result = null; target.RequestNavigate(new Uri("", UriKind.Relative), nr => result = nr); navigationCallback(true); Assert.NotNull(result); - Assert.Same(targetException, result.Error); + Assert.Same(targetException, result.Exception); } [Fact] @@ -908,7 +909,7 @@ namespace Prism.Forms.Regions.Tests // Verify viewMock.As() - .Verify(v => v.OnNavigatedFrom(It.Is(ctx => ctx.Uri == navigationUri && ctx.Parameters.Count() == 0))); + .Verify(v => v.OnNavigatedFrom(It.Is(ctx => ctx.Uri == navigationUri && ctx.Parameters.Count() == 0))); } [Fact] @@ -923,7 +924,7 @@ namespace Prism.Forms.Regions.Tests var viewMock = new Mock(); viewMock .As() - .Setup(x => x.OnNavigatedFrom(It.IsAny())).Callback(() => navigationFromInvoked = true); + .Setup(x => x.OnNavigatedFrom(It.IsAny())).Callback(() => navigationFromInvoked = true); var view = viewMock.Object; region.Add(view); @@ -958,7 +959,7 @@ namespace Prism.Forms.Regions.Tests } [Fact] - public void WhenNavigatingFromActiveViewWithNavigatinAwareDataConext_NotifiesContextOfNavigatingFrom() + public void WhenNavigatingFromActiveViewWithNavigationAwareDataContext_NotifiesContextOfNavigatingFrom() { // Arrange var region = new Region(); @@ -993,7 +994,7 @@ namespace Prism.Forms.Regions.Tests target.RequestNavigate(navigationUri, nr => { }); // Verify - mockBindingContext.Verify(v => v.OnNavigatedFrom(It.Is(ctx => ctx.Uri == navigationUri && ctx.Parameters.Count() == 0))); + mockBindingContext.Verify(v => v.OnNavigatedFrom(It.Is(ctx => ctx.Uri == navigationUri && ctx.Parameters.Count() == 0))); } [Fact] @@ -1014,7 +1015,7 @@ namespace Prism.Forms.Regions.Tests ExceptionAssert.Throws( () => { - target.RequestNavigate(navigationUri, null); + target.RequestNavigate(navigationUri); }); } @@ -1029,7 +1030,7 @@ namespace Prism.Forms.Regions.Tests var target = new RegionNavigationService(container, contentLoader, journal); Exception error = null; - target.RequestNavigate(navigationUri, nr => error = nr.Error); + target.RequestNavigate(navigationUri, nr => error = nr.Exception); Assert.NotNull(error); Assert.IsType(error); @@ -1048,7 +1049,7 @@ namespace Prism.Forms.Regions.Tests }; Exception error = null; - target.RequestNavigate(null, nr => error = nr.Error); + target.RequestNavigate("", nr => error = nr.Exception); Assert.NotNull(error); Assert.IsType(error); @@ -1066,7 +1067,7 @@ namespace Prism.Forms.Regions.Tests var contentLoaderMock = new Mock(); contentLoaderMock - .Setup(cl => cl.LoadContent(region, It.IsAny())) + .Setup(cl => cl.LoadContent(region, It.IsAny())) .Throws(); var container = containerMock.Object; @@ -1089,7 +1090,7 @@ namespace Prism.Forms.Regions.Tests // Act bool? isNavigationSuccessful = null; - target.RequestNavigate(new Uri("invalid", UriKind.Relative), nr => isNavigationSuccessful = nr.Result); + target.RequestNavigate(new Uri("invalid", UriKind.Relative), nr => isNavigationSuccessful = nr.Success); // Verify Assert.False(isNavigationSuccessful.Value); @@ -1105,9 +1106,9 @@ namespace Prism.Forms.Regions.Tests var view1Mock = new Mock(); view1Mock - .As() - .Setup(ina => ina.ConfirmNavigationRequest(It.IsAny(), It.IsAny>())) - .Callback>((nc, c) => c(false)) + .As() + .Setup(ina => ina.ConfirmNavigationRequest(It.IsAny(), It.IsAny>())) + .Callback>((nc, c) => c(false)) .Verifiable(); var view1 = view1Mock.Object; @@ -1126,7 +1127,7 @@ namespace Prism.Forms.Regions.Tests var contentLoaderMock = new Mock(); contentLoaderMock - .Setup(cl => cl.LoadContent(region, It.IsAny())) + .Setup(cl => cl.LoadContent(region, It.IsAny())) .Returns(view2); var container = containerMock.Object; @@ -1149,7 +1150,7 @@ namespace Prism.Forms.Regions.Tests // Act bool? isNavigationSuccessful = null; - target.RequestNavigate(navigationUri, nr => isNavigationSuccessful = nr.Result); + target.RequestNavigate(navigationUri, nr => isNavigationSuccessful = nr.Success); // Verify view1Mock.VerifyAll(); @@ -1164,10 +1165,10 @@ namespace Prism.Forms.Regions.Tests // Prepare var region = new Region { Name = "RegionName" }; - var viewModel1Mock = new Mock(); + var viewModel1Mock = new Mock(); viewModel1Mock - .Setup(ina => ina.ConfirmNavigationRequest(It.IsAny(), It.IsAny>())) - .Callback>((nc, c) => c(false)) + .Setup(ina => ina.ConfirmNavigationRequest(It.IsAny(), It.IsAny>())) + .Callback>((nc, c) => c(false)) .Verifiable(); var view1Mock = new Mock(); @@ -1188,7 +1189,7 @@ namespace Prism.Forms.Regions.Tests var contentLoaderMock = new Mock(); contentLoaderMock - .Setup(cl => cl.LoadContent(region, It.IsAny())) + .Setup(cl => cl.LoadContent(region, It.IsAny())) .Returns(view2); var container = containerMock.Object; @@ -1211,7 +1212,7 @@ namespace Prism.Forms.Regions.Tests // Act bool? isNavigationSuccessful = null; - target.RequestNavigate(navigationUri, nr => isNavigationSuccessful = nr.Result); + target.RequestNavigate(navigationUri, nr => isNavigationSuccessful = nr.Success); // Verify viewModel1Mock.VerifyAll(); diff --git a/tests/Forms/Prism.Forms.Regions.Tests/Tests/RegionViewRegistryFixture.cs b/tests/Forms/Prism.Forms.Regions.Tests/Tests/RegionViewRegistryFixture.cs index e89ccc82..29042e43 100644 --- a/tests/Forms/Prism.Forms.Regions.Tests/Tests/RegionViewRegistryFixture.cs +++ b/tests/Forms/Prism.Forms.Regions.Tests/Tests/RegionViewRegistryFixture.cs @@ -44,7 +44,7 @@ namespace Prism.Forms.Regions.Tests Assert.NotNull(listener.onViewRegisteredArguments); Assert.NotNull(listener.onViewRegisteredArguments.GetView); - var result = listener.onViewRegisteredArguments.GetView(); + var result = listener.onViewRegisteredArguments.GetView(containerMock.Object); Assert.NotNull(result); Assert.IsType(result); } diff --git a/tests/Maui/Prism.DryIoc.Maui.Tests/Fixtures/Regions/RegionFixture.cs b/tests/Maui/Prism.DryIoc.Maui.Tests/Fixtures/Regions/RegionFixture.cs index c3c39dbd..83e81318 100644 --- a/tests/Maui/Prism.DryIoc.Maui.Tests/Fixtures/Regions/RegionFixture.cs +++ b/tests/Maui/Prism.DryIoc.Maui.Tests/Fixtures/Regions/RegionFixture.cs @@ -101,7 +101,8 @@ public class RegionFixture : TestBase var region = regionManager.Regions.First(x => x.Name == "ContentRegion"); var activeView = region.ActiveViews.First(); Assert.IsType(activeView); - var viewModel = activeView.BindingContext as MockRegionViewAViewModel; + var activeViewAsMockRegionViewA = activeView as MockRegionViewA; + var viewModel = activeViewAsMockRegionViewA.BindingContext as MockRegionViewAViewModel; Assert.NotNull(viewModel); Assert.NotNull(viewModel.Page); diff --git a/tests/Maui/Prism.DryIoc.Maui.Tests/Mocks/ViewModels/MockRegionViewAViewModel.cs b/tests/Maui/Prism.DryIoc.Maui.Tests/Mocks/ViewModels/MockRegionViewAViewModel.cs index 740ac9bc..a6680823 100644 --- a/tests/Maui/Prism.DryIoc.Maui.Tests/Mocks/ViewModels/MockRegionViewAViewModel.cs +++ b/tests/Maui/Prism.DryIoc.Maui.Tests/Mocks/ViewModels/MockRegionViewAViewModel.cs @@ -29,17 +29,17 @@ public class MockRegionViewAViewModel : BindableBase, IRegionAware, IInitialize Message = message; } - public bool IsNavigationTarget(INavigationContext navigationContext) + public bool IsNavigationTarget(NavigationContext navigationContext) { return navigationContext.NavigatedName() == "MockRegionViewA"; } - public void OnNavigatedFrom(INavigationContext navigationContext) + public void OnNavigatedFrom(NavigationContext navigationContext) { } - public void OnNavigatedTo(INavigationContext navigationContext) + public void OnNavigatedTo(NavigationContext navigationContext) { } diff --git a/tests/Wpf/Prism.IocContainer.Wpf.Tests.Support/Mocks/MockRegionManager.cs b/tests/Wpf/Prism.IocContainer.Wpf.Tests.Support/Mocks/MockRegionManager.cs index 22a1eac7..b31f8cf7 100644 --- a/tests/Wpf/Prism.IocContainer.Wpf.Tests.Support/Mocks/MockRegionManager.cs +++ b/tests/Wpf/Prism.IocContainer.Wpf.Tests.Support/Mocks/MockRegionManager.cs @@ -1,4 +1,5 @@ using System; +using Prism.Ioc; using Prism.Navigation; using Prism.Regions; @@ -89,5 +90,10 @@ namespace Prism.IocContainer.Wpf.Tests.Support.Mocks { throw new NotImplementedException(); } + + public IRegionManager RegisterViewWithRegion(string regionName, Func getContentDelegate) + { + throw new NotImplementedException(); + } } } diff --git a/tests/Wpf/Prism.Wpf.Tests/Mocks/MockRegionManager.cs b/tests/Wpf/Prism.Wpf.Tests/Mocks/MockRegionManager.cs index 49642ab4..838445b5 100644 --- a/tests/Wpf/Prism.Wpf.Tests/Mocks/MockRegionManager.cs +++ b/tests/Wpf/Prism.Wpf.Tests/Mocks/MockRegionManager.cs @@ -1,6 +1,7 @@ using System; using System.Collections; using System.Collections.Generic; +using Prism.Ioc; using Prism.Navigation; using Prism.Regions; @@ -37,7 +38,7 @@ namespace Prism.Wpf.Tests.Mocks throw new NotImplementedException(); } - public IRegionManager RegisterViewWithRegion(string regionName, Func getContentDelegate) + public IRegionManager RegisterViewWithRegion(string regionName, Func getContentDelegate) { throw new NotImplementedException(); } diff --git a/tests/Wpf/Prism.Wpf.Tests/Regions/Behaviors/AutoPopulateRegionBehaviorFixture.cs b/tests/Wpf/Prism.Wpf.Tests/Regions/Behaviors/AutoPopulateRegionBehaviorFixture.cs index 4c4b5a13..a0903376 100644 --- a/tests/Wpf/Prism.Wpf.Tests/Regions/Behaviors/AutoPopulateRegionBehaviorFixture.cs +++ b/tests/Wpf/Prism.Wpf.Tests/Regions/Behaviors/AutoPopulateRegionBehaviorFixture.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; +using Prism.Ioc; using Prism.Regions; using Prism.Regions.Behaviors; using Prism.Wpf.Tests.Mocks; @@ -94,7 +95,7 @@ namespace Prism.Wpf.Tests.Regions.Behaviors public event EventHandler ContentRegistered; - public IEnumerable GetContents(string regionName) + public IEnumerable GetContents(string regionName, IContainerProvider container) { GetContentsCalled = true; this.GetContentsArgumentRegionName = regionName; @@ -103,7 +104,7 @@ namespace Prism.Wpf.Tests.Regions.Behaviors public void RaiseContentRegistered(string regionName, object view) { - this.ContentRegistered(this, new ViewRegisteredEventArgs(regionName, () => view)); + this.ContentRegistered(this, new ViewRegisteredEventArgs(regionName, _ => view)); } public void RegisterViewWithRegion(string regionName, Type viewType) @@ -111,7 +112,12 @@ namespace Prism.Wpf.Tests.Regions.Behaviors throw new NotImplementedException(); } - public void RegisterViewWithRegion(string regionName, Func getContentDelegate) + public void RegisterViewWithRegion(string regionName, Func getContentDelegate) + { + throw new NotImplementedException(); + } + + public void RegisterViewWithRegion(string regionName, string targetName) { throw new NotImplementedException(); } diff --git a/tests/Wpf/Prism.Wpf.Tests/Regions/Behaviors/RegionManagerRegistrationBehaviorFixture.cs b/tests/Wpf/Prism.Wpf.Tests/Regions/Behaviors/RegionManagerRegistrationBehaviorFixture.cs index 326948ef..6635b65c 100644 --- a/tests/Wpf/Prism.Wpf.Tests/Regions/Behaviors/RegionManagerRegistrationBehaviorFixture.cs +++ b/tests/Wpf/Prism.Wpf.Tests/Regions/Behaviors/RegionManagerRegistrationBehaviorFixture.cs @@ -3,6 +3,7 @@ using System.Collections; using System.Collections.Generic; using System.Threading.Tasks; using System.Windows.Controls; +using Prism.Ioc; using Prism.Navigation; using Prism.Regions; using Prism.Regions.Behaviors; @@ -242,7 +243,7 @@ namespace Prism.Wpf.Tests.Regions.Behaviors throw new NotImplementedException(); } - public IRegionManager RegisterViewWithRegion(string regionName, Func getContentDelegate) + public IRegionManager RegisterViewWithRegion(string regionName, Func getContentDelegate) { throw new NotImplementedException(); } diff --git a/tests/Wpf/Prism.Wpf.Tests/Regions/NavigationAsyncExtensionsFixture.cs b/tests/Wpf/Prism.Wpf.Tests/Regions/NavigationAsyncExtensionsFixture.cs index 2b9c1783..dcdcc71a 100644 --- a/tests/Wpf/Prism.Wpf.Tests/Regions/NavigationAsyncExtensionsFixture.cs +++ b/tests/Wpf/Prism.Wpf.Tests/Regions/NavigationAsyncExtensionsFixture.cs @@ -2,6 +2,7 @@ using System; using Moq; +using Prism.Navigation; using Prism.Regions; using Xunit; diff --git a/tests/Wpf/Prism.Wpf.Tests/Regions/RegionFixture.cs b/tests/Wpf/Prism.Wpf.Tests/Regions/RegionFixture.cs index 3ff8bfbb..a3f01dc1 100644 --- a/tests/Wpf/Prism.Wpf.Tests/Regions/RegionFixture.cs +++ b/tests/Wpf/Prism.Wpf.Tests/Regions/RegionFixture.cs @@ -471,7 +471,7 @@ namespace Prism.Wpf.Tests.Regions throw new NotImplementedException(); } - public IRegionManager RegisterViewWithRegion(string regionName, Func getContentDelegate) + public IRegionManager RegisterViewWithRegion(string regionName, Func getContentDelegate) { throw new NotImplementedException(); } diff --git a/tests/Wpf/Prism.Wpf.Tests/Regions/RegionManagerFixture.cs b/tests/Wpf/Prism.Wpf.Tests/Regions/RegionManagerFixture.cs index 458ced82..0c67c263 100644 --- a/tests/Wpf/Prism.Wpf.Tests/Regions/RegionManagerFixture.cs +++ b/tests/Wpf/Prism.Wpf.Tests/Regions/RegionManagerFixture.cs @@ -408,9 +408,9 @@ namespace Prism.Wpf.Tests.Regions var mockRegionContentRegistry = new MockRegionContentRegistry(); string regionName = null; - Func contentDelegate = null; + Func contentDelegate = null; - Func expectedDelegate = () => true; + Func expectedDelegate = _ => true; mockRegionContentRegistry.RegisterContentWithDelegate = (name, usedDelegate) => { regionName = name; @@ -474,19 +474,24 @@ namespace Prism.Wpf.Tests.Regions internal class MockRegionContentRegistry : IRegionViewRegistry { public Func RegisterContentWithViewType; - public Func, object> RegisterContentWithDelegate; + public Func, object> RegisterContentWithDelegate; public event EventHandler ContentRegistered; - public IEnumerable GetContents(string regionName) + public IEnumerable GetContents(string regionName, IContainerProvider container) { return null; } + public void RegisterViewWithRegion(string regionName, string targetName) + { + throw new NotImplementedException(); + } + void IRegionViewRegistry.RegisterViewWithRegion(string regionName, Type viewType) { RegisterContentWithViewType?.Invoke(regionName, viewType); } - void IRegionViewRegistry.RegisterViewWithRegion(string regionName, Func getContentDelegate) + void IRegionViewRegistry.RegisterViewWithRegion(string regionName, Func getContentDelegate) { RegisterContentWithDelegate?.Invoke(regionName, getContentDelegate); diff --git a/tests/Wpf/Prism.Wpf.Tests/Regions/RegionManagerRequestNavigateFixture.cs b/tests/Wpf/Prism.Wpf.Tests/Regions/RegionManagerRequestNavigateFixture.cs index fc04ce9f..7c86855d 100644 --- a/tests/Wpf/Prism.Wpf.Tests/Regions/RegionManagerRequestNavigateFixture.cs +++ b/tests/Wpf/Prism.Wpf.Tests/Regions/RegionManagerRequestNavigateFixture.cs @@ -56,19 +56,19 @@ namespace Prism.Wpf.Tests.Regions result = null; regionManager.RequestNavigate(nonExistentRegion, source, (r) => result = r, parameters); - Assert.Equal(false, result.Result); + Assert.False(result.Success); result = null; regionManager.RequestNavigate(nonExistentRegion, source, (r) => result = r); - Assert.Equal(false, result.Result); + Assert.False(result.Success); result = null; regionManager.RequestNavigate(nonExistentRegion, sourceUri, (r) => result = r, parameters); - Assert.Equal(false, result.Result); + Assert.False(result.Success); result = null; regionManager.RequestNavigate(nonExistentRegion, sourceUri, (r) => result = r); - Assert.Equal(false, result.Result); + Assert.False(result.Success); } [Fact] diff --git a/tests/Wpf/Prism.Wpf.Tests/Regions/RegionNavigationServiceFixture.new.cs b/tests/Wpf/Prism.Wpf.Tests/Regions/RegionNavigationServiceFixture.new.cs index b8a49110..862a09dc 100644 --- a/tests/Wpf/Prism.Wpf.Tests/Regions/RegionNavigationServiceFixture.new.cs +++ b/tests/Wpf/Prism.Wpf.Tests/Regions/RegionNavigationServiceFixture.new.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Windows; using Moq; using Prism.Ioc; +using Prism.Navigation; using Prism.Regions; using Xunit; @@ -40,7 +41,7 @@ namespace Prism.Wpf.Tests.Regions // Act bool isNavigationSuccessful = false; - target.RequestNavigate(viewUri, nr => isNavigationSuccessful = nr.Result == true); + target.RequestNavigate(viewUri, nr => isNavigationSuccessful = nr.Success == true); // Verify Assert.True(isNavigationSuccessful); @@ -76,7 +77,7 @@ namespace Prism.Wpf.Tests.Regions // Act bool isNavigationSuccessful = false; - target.RequestNavigate(viewUri, nr => isNavigationSuccessful = nr.Result == true); + target.RequestNavigate(viewUri, nr => isNavigationSuccessful = nr.Success == true); // Verify Assert.True(isNavigationSuccessful); @@ -116,7 +117,7 @@ namespace Prism.Wpf.Tests.Regions new Uri(otherType.GetType().Name, UriKind.Relative), nr => { - error = nr.Error; + error = nr.Exception; }); // Verify @@ -148,9 +149,9 @@ namespace Prism.Wpf.Tests.Regions target.RequestNavigate((Uri)null, nr => navigationResult = nr); // Verify - Assert.False(navigationResult.Result.Value); - Assert.NotNull(navigationResult.Error); - Assert.IsType(navigationResult.Error); + Assert.False(navigationResult.Success); + Assert.NotNull(navigationResult.Exception); + Assert.IsType(navigationResult.Exception); } [Fact] @@ -435,7 +436,7 @@ namespace Prism.Wpf.Tests.Regions // Act var navigationSucceeded = false; - target.RequestNavigate(navigationUri, nr => { navigationSucceeded = nr.Result == true; }); + target.RequestNavigate(navigationUri, nr => { navigationSucceeded = nr.Success == true; }); // Verify view1Mock.VerifyAll(); @@ -480,7 +481,7 @@ namespace Prism.Wpf.Tests.Regions // Act var navigationFailed = false; - target.RequestNavigate(navigationUri, nr => { navigationFailed = nr.Result == false; }); + target.RequestNavigate(navigationUri, nr => { navigationFailed = nr.Success == false; }); // Verify view1Mock.VerifyAll(); @@ -567,7 +568,7 @@ namespace Prism.Wpf.Tests.Regions // Act var navigationSucceeded = false; - target.RequestNavigate(navigationUri, nr => { navigationSucceeded = nr.Result == true; }); + target.RequestNavigate(navigationUri, nr => { navigationSucceeded = nr.Success == true; }); // Verify view1DataContextMock.VerifyAll(); @@ -614,7 +615,7 @@ namespace Prism.Wpf.Tests.Regions // Act var navigationFailed = false; - target.RequestNavigate(navigationUri, nr => { navigationFailed = nr.Result == false; }); + target.RequestNavigate(navigationUri, nr => { navigationFailed = nr.Success == false; }); // Verify view1DataContextMock.VerifyAll(); @@ -662,8 +663,8 @@ namespace Prism.Wpf.Tests.Regions bool firstNavigation = false; bool secondNavigation = false; - target.RequestNavigate(navigationUri, nr => firstNavigation = nr.Result.Value); - target.RequestNavigate(navigationUri, nr => secondNavigation = nr.Result.Value); + target.RequestNavigate(navigationUri, nr => firstNavigation = nr.Success); + target.RequestNavigate(navigationUri, nr => secondNavigation = nr.Success); Assert.Equal(2, confirmationRequests.Count); @@ -717,8 +718,8 @@ namespace Prism.Wpf.Tests.Regions bool firstNavigation = false; bool secondNavigation = false; - target.RequestNavigate(navigationUri, nr => firstNavigation = nr.Result.Value); - target.RequestNavigate(navigationUri, nr => secondNavigation = nr.Result.Value); + target.RequestNavigate(navigationUri, nr => firstNavigation = nr.Success); + target.RequestNavigate(navigationUri, nr => secondNavigation = nr.Success); Assert.Equal(2, confirmationRequests.Count); @@ -766,7 +767,7 @@ namespace Prism.Wpf.Tests.Regions // Act bool isNavigationSuccessful = false; - target.RequestNavigate(viewUri, nr => isNavigationSuccessful = nr.Result == true); + target.RequestNavigate(viewUri, nr => isNavigationSuccessful = nr.Success == true); // Verify Assert.True(isNavigationSuccessful); @@ -810,7 +811,7 @@ namespace Prism.Wpf.Tests.Regions // Act bool isNavigationSuccessful = false; - target.RequestNavigate(viewUri, nr => isNavigationSuccessful = nr.Result == true); + target.RequestNavigate(viewUri, nr => isNavigationSuccessful = nr.Success == true); // Verify Assert.True(isNavigationSuccessful); @@ -850,7 +851,7 @@ namespace Prism.Wpf.Tests.Regions navigationCallback(true); Assert.NotNull(result); - Assert.Same(targetException, result.Error); + Assert.Same(targetException, result.Exception); } [Fact] @@ -1002,7 +1003,7 @@ namespace Prism.Wpf.Tests.Regions RegionNavigationService target = new RegionNavigationService(container, contentLoader, journal); Exception error = null; - target.RequestNavigate(navigationUri, nr => error = nr.Error); + target.RequestNavigate(navigationUri, nr => error = nr.Exception); Assert.NotNull(error); Assert.IsType(error); @@ -1021,7 +1022,7 @@ namespace Prism.Wpf.Tests.Regions }; Exception error = null; - target.RequestNavigate(null, nr => error = nr.Error); + target.RequestNavigate(null, nr => error = nr.Exception); Assert.NotNull(error); Assert.IsType(error); @@ -1062,7 +1063,7 @@ namespace Prism.Wpf.Tests.Regions // Act bool? isNavigationSuccessful = null; - target.RequestNavigate(new Uri("invalid", UriKind.Relative), nr => isNavigationSuccessful = nr.Result); + target.RequestNavigate(new Uri("invalid", UriKind.Relative), nr => isNavigationSuccessful = nr.Success); // Verify Assert.False(isNavigationSuccessful.Value); @@ -1121,7 +1122,7 @@ namespace Prism.Wpf.Tests.Regions // Act bool? isNavigationSuccessful = null; - target.RequestNavigate(navigationUri, nr => isNavigationSuccessful = nr.Result); + target.RequestNavigate(navigationUri, nr => isNavigationSuccessful = nr.Success); // Verify view1Mock.VerifyAll(); @@ -1183,7 +1184,7 @@ namespace Prism.Wpf.Tests.Regions // Act bool? isNavigationSuccessful = null; - target.RequestNavigate(navigationUri, nr => isNavigationSuccessful = nr.Result); + target.RequestNavigate(navigationUri, nr => isNavigationSuccessful = nr.Success); // Verify viewModel1Mock.VerifyAll(); diff --git a/tests/Wpf/Prism.Wpf.Tests/Regions/RegionViewRegistryFixture.cs b/tests/Wpf/Prism.Wpf.Tests/Regions/RegionViewRegistryFixture.cs index 2157a53d..925e45b2 100644 --- a/tests/Wpf/Prism.Wpf.Tests/Regions/RegionViewRegistryFixture.cs +++ b/tests/Wpf/Prism.Wpf.Tests/Regions/RegionViewRegistryFixture.cs @@ -44,7 +44,7 @@ namespace Prism.Wpf.Tests.Regions Assert.NotNull(listener.onViewRegisteredArguments); Assert.NotNull(listener.onViewRegisteredArguments.GetView); - var result = listener.onViewRegisteredArguments.GetView(); + var result = listener.onViewRegisteredArguments.GetView(containerMock.Object); Assert.NotNull(result); Assert.IsType(result); } -- GitLab