Skip to content

Commit

Permalink
fix: ParameterViewStackService passing null on construction (#309)
Browse files Browse the repository at this point in the history
  • Loading branch information
RLittlesII authored Dec 31, 2020
1 parent 88b7f0e commit e1cdd7e
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<System.Collections.Immutable.IImmutableList<Sextant.IViewModel>> ModalStack { get; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<System.Collections.Immutable.IImmutableList<Sextant.IViewModel>> ModalStack { get; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@ public class TheConstructor
public TheConstructor() => Locator.GetLocator().UnregisterAll<IViewModelFactory>();

/// <summary>
/// Test that the object constructed uses the static instance of ViewModelFactory.
/// Test that the object constructed uses a new instance of ViewModelFactory.
/// </summary>
[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<ViewModelFactoryNotFoundException>();
result.Should().BeNull();
}

/// <summary>
Expand Down
8 changes: 4 additions & 4 deletions src/Sextant.Tests/Navigation/ViewStackServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@ public class TheConstructor
public TheConstructor() => Locator.GetLocator().UnregisterAll<IViewModelFactory>();

/// <summary>
/// Test that the object constructed uses the static instance of ViewModelFactory.
/// Test that the object constructed uses a new instance of ViewModelFactory.
/// </summary>
[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<ViewModelFactoryNotFoundException>();
result.Should().BeNull();
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/Sextant/Navigation/ParameterViewStackService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public sealed class ParameterViewStackService : ParameterViewStackServiceBase
/// </summary>
/// <param name="view">The view.</param>
public ParameterViewStackService(IView view)
: this(view, null!)
: this(view, new DefaultViewModelFactory())
{
}

Expand Down
4 changes: 2 additions & 2 deletions src/Sextant/Navigation/ViewStackService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public sealed class ViewStackService : ViewStackServiceBase
/// </summary>
/// <param name="view">The view.</param>
public ViewStackService(IView view)
: this(view, null)
: this(view, new DefaultViewModelFactory())
{
}

Expand All @@ -26,7 +26,7 @@ public ViewStackService(IView view)
/// </summary>
/// <param name="view">The view.</param>
/// <param name="viewModelFactory">The view model factory.</param>
public ViewStackService(IView view, IViewModelFactory? viewModelFactory)
public ViewStackService(IView view, IViewModelFactory viewModelFactory)
: base(view, viewModelFactory)
{
}
Expand Down
4 changes: 2 additions & 2 deletions src/Sextant/Navigation/ViewStackServiceBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ public abstract class ViewStackServiceBase : IViewStackService, IDisposable, IEn
/// </summary>
/// <param name="view">The view.</param>
/// <param name="viewModelFactory">The view model factory.</param>
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<IImmutableList<IViewModel>>(ImmutableList<IViewModel>.Empty);
PageSubject = new BehaviorSubject<IImmutableList<IViewModel>>(ImmutableList<IViewModel>.Empty);

Expand Down

0 comments on commit e1cdd7e

Please sign in to comment.