diff --git a/src/Sextant.Tests/API/ApiApprovalTests.Sextant.net5.0.approved.txt b/src/Sextant.Tests/API/ApiApprovalTests.Sextant.net5.0.approved.txt index a492fa86..73f6cd13 100644 --- a/src/Sextant.Tests/API/ApiApprovalTests.Sextant.net5.0.approved.txt +++ b/src/Sextant.Tests/API/ApiApprovalTests.Sextant.net5.0.approved.txt @@ -153,11 +153,11 @@ namespace Sextant public sealed class ViewStackService : Sextant.ViewStackServiceBase { public ViewStackService(Sextant.IView view) { } - public ViewStackService(Sextant.IView view, Sextant.IViewModelFactory? viewModelFactory) { } + public ViewStackService(Sextant.IView view, Sextant.IViewModelFactory viewModelFactory) { } } public abstract class ViewStackServiceBase : Sextant.IViewStackService, Splat.IEnableLogger, System.IDisposable { - protected ViewStackServiceBase(Sextant.IView view, Sextant.IViewModelFactory? viewModelFactory) { } + protected ViewStackServiceBase(Sextant.IView view, Sextant.IViewModelFactory viewModelFactory) { } protected Sextant.IViewModelFactory Factory { get; } protected Splat.IFullLogger Logger { get; } public System.IObservable> ModalStack { get; } diff --git a/src/Sextant.Tests/API/ApiApprovalTests.Sextant.netcoreapp3.1.approved.txt b/src/Sextant.Tests/API/ApiApprovalTests.Sextant.netcoreapp3.1.approved.txt index 94739326..54c2dd39 100644 --- a/src/Sextant.Tests/API/ApiApprovalTests.Sextant.netcoreapp3.1.approved.txt +++ b/src/Sextant.Tests/API/ApiApprovalTests.Sextant.netcoreapp3.1.approved.txt @@ -153,11 +153,11 @@ namespace Sextant public sealed class ViewStackService : Sextant.ViewStackServiceBase { public ViewStackService(Sextant.IView view) { } - public ViewStackService(Sextant.IView view, Sextant.IViewModelFactory? viewModelFactory) { } + public ViewStackService(Sextant.IView view, Sextant.IViewModelFactory viewModelFactory) { } } public abstract class ViewStackServiceBase : Sextant.IViewStackService, Splat.IEnableLogger, System.IDisposable { - protected ViewStackServiceBase(Sextant.IView view, Sextant.IViewModelFactory? viewModelFactory) { } + protected ViewStackServiceBase(Sextant.IView view, Sextant.IViewModelFactory viewModelFactory) { } protected Sextant.IViewModelFactory Factory { get; } protected Splat.IFullLogger Logger { get; } public System.IObservable> ModalStack { get; } diff --git a/src/Sextant.Tests/Navigation/ParameterViewStackServiceTests.cs b/src/Sextant.Tests/Navigation/ParameterViewStackServiceTests.cs index 7ab625d9..9d596b1f 100644 --- a/src/Sextant.Tests/Navigation/ParameterViewStackServiceTests.cs +++ b/src/Sextant.Tests/Navigation/ParameterViewStackServiceTests.cs @@ -31,16 +31,16 @@ public class TheConstructor public TheConstructor() => Locator.GetLocator().UnregisterAll(); /// - /// Test that the object constructed uses the static instance of ViewModelFactory. + /// Test that the object constructed uses a new instance of ViewModelFactory. /// [Fact] - public void Should_Throw_If_View_Model_Factory_Current_Null() + public void Should_Not_Throw_If_View_Model_Factory_Current_Null() { // Given, When var result = Record.Exception(() => new ParameterViewStackServiceFixture().WithFactory(null!)); // Then - result.Should().BeOfType(); + result.Should().BeNull(); } /// diff --git a/src/Sextant.Tests/Navigation/ViewStackServiceTests.cs b/src/Sextant.Tests/Navigation/ViewStackServiceTests.cs index 07c5d8cb..b14771ad 100644 --- a/src/Sextant.Tests/Navigation/ViewStackServiceTests.cs +++ b/src/Sextant.Tests/Navigation/ViewStackServiceTests.cs @@ -33,16 +33,16 @@ public class TheConstructor public TheConstructor() => Locator.GetLocator().UnregisterAll(); /// - /// Test that the object constructed uses the static instance of ViewModelFactory. + /// Test that the object constructed uses a new instance of ViewModelFactory. /// [Fact] - public void Should_Throw_If_View_Model_Factory_Current_Null() + public void Should_Not_Throw_If_View_Model_Factory_Current_Null() { // Given, When - var result = Record.Exception(() => (ViewStackService)new ViewStackServiceFixture().WithFactory(null!)); + var result = Record.Exception(() => new ParameterViewStackServiceFixture().WithFactory(null!)); // Then - result.Should().BeOfType(); + result.Should().BeNull(); } /// diff --git a/src/Sextant/Navigation/ParameterViewStackService.cs b/src/Sextant/Navigation/ParameterViewStackService.cs index 149f8692..c24c430f 100644 --- a/src/Sextant/Navigation/ParameterViewStackService.cs +++ b/src/Sextant/Navigation/ParameterViewStackService.cs @@ -17,7 +17,7 @@ public sealed class ParameterViewStackService : ParameterViewStackServiceBase /// /// The view. public ParameterViewStackService(IView view) - : this(view, null!) + : this(view, new DefaultViewModelFactory()) { } diff --git a/src/Sextant/Navigation/ViewStackService.cs b/src/Sextant/Navigation/ViewStackService.cs index 9d6324f6..a17439c6 100644 --- a/src/Sextant/Navigation/ViewStackService.cs +++ b/src/Sextant/Navigation/ViewStackService.cs @@ -17,7 +17,7 @@ public sealed class ViewStackService : ViewStackServiceBase /// /// The view. public ViewStackService(IView view) - : this(view, null) + : this(view, new DefaultViewModelFactory()) { } @@ -26,7 +26,7 @@ public ViewStackService(IView view) /// /// The view. /// The view model factory. - public ViewStackService(IView view, IViewModelFactory? viewModelFactory) + public ViewStackService(IView view, IViewModelFactory viewModelFactory) : base(view, viewModelFactory) { } diff --git a/src/Sextant/Navigation/ViewStackServiceBase.cs b/src/Sextant/Navigation/ViewStackServiceBase.cs index bea262de..763e8357 100644 --- a/src/Sextant/Navigation/ViewStackServiceBase.cs +++ b/src/Sextant/Navigation/ViewStackServiceBase.cs @@ -28,11 +28,11 @@ public abstract class ViewStackServiceBase : IViewStackService, IDisposable, IEn /// /// The view. /// The view model factory. - protected ViewStackServiceBase(IView view, IViewModelFactory? viewModelFactory) + protected ViewStackServiceBase(IView view, IViewModelFactory viewModelFactory) { Logger = this.Log(); View = view ?? throw new ArgumentNullException(nameof(view)); - Factory = viewModelFactory ?? ViewModelFactory.Current; + Factory = viewModelFactory; ModalSubject = new BehaviorSubject>(ImmutableList.Empty); PageSubject = new BehaviorSubject>(ImmutableList.Empty);