-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pre-fill Last Loaded/Saved Config Name (#228)
- Loading branch information
1 parent
d6e99f2
commit 4ed422f
Showing
7 changed files
with
83 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
src/BaroquenMelody.Library/Store/Actions/UpdateLastLoadedConfigurationName.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
namespace BaroquenMelody.Library.Store.Actions; | ||
|
||
public sealed record UpdateLastLoadedConfigurationName(string LastLoadedConfigurationName); |
14 changes: 14 additions & 0 deletions
14
src/BaroquenMelody.Library/Store/Reducers/SavedCompositionConfigurationReducers.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using BaroquenMelody.Library.Store.Actions; | ||
using BaroquenMelody.Library.Store.State; | ||
using Fluxor; | ||
|
||
namespace BaroquenMelody.Library.Store.Reducers; | ||
|
||
public static class SavedCompositionConfigurationReducers | ||
{ | ||
[ReducerMethod] | ||
public static SavedCompositionConfigurationState ReduceUpdateLastLoadedConfigurationName( | ||
SavedCompositionConfigurationState state, | ||
UpdateLastLoadedConfigurationName action | ||
) => new(action.LastLoadedConfigurationName); | ||
} |
12 changes: 12 additions & 0 deletions
12
src/BaroquenMelody.Library/Store/State/SavedCompositionConfigurationState.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using Fluxor; | ||
|
||
namespace BaroquenMelody.Library.Store.State; | ||
|
||
[FeatureState] | ||
public sealed record SavedCompositionConfigurationState(string LastLoadedConfigurationName) | ||
{ | ||
public SavedCompositionConfigurationState() | ||
: this(string.Empty) | ||
{ | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
...BaroquenMelody.Library.Tests/Store/Reducers/SavedCompositionConfigurationReducersTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using BaroquenMelody.Library.Store.Actions; | ||
using BaroquenMelody.Library.Store.Reducers; | ||
using BaroquenMelody.Library.Store.State; | ||
using FluentAssertions; | ||
using NUnit.Framework; | ||
|
||
namespace BaroquenMelody.Library.Tests.Store.Reducers; | ||
|
||
[TestFixture] | ||
internal sealed class SavedCompositionConfigurationReducersTests | ||
{ | ||
[Test] | ||
public void ReduceUpdateLastLoadedConfigurationName_with_empty_state_updates_name() | ||
{ | ||
// arrange | ||
var state = new SavedCompositionConfigurationState(); | ||
var action = new UpdateLastLoadedConfigurationName("NewLastLoadedConfigurationName"); | ||
|
||
// act | ||
var newState = SavedCompositionConfigurationReducers.ReduceUpdateLastLoadedConfigurationName(state, action); | ||
|
||
// assert | ||
newState.LastLoadedConfigurationName.Should().Be("NewLastLoadedConfigurationName"); | ||
} | ||
|
||
[Test] | ||
public void ReduceUpdateLastLoadedConfigurationName_with_existing_state_updates_name() | ||
{ | ||
// arrange | ||
var state = new SavedCompositionConfigurationState("LastLoadedConfigurationName"); | ||
var action = new UpdateLastLoadedConfigurationName("NewLastLoadedConfigurationName"); | ||
|
||
// act | ||
var newState = SavedCompositionConfigurationReducers.ReduceUpdateLastLoadedConfigurationName(state, action); | ||
|
||
// assert | ||
newState.LastLoadedConfigurationName.Should().Be("NewLastLoadedConfigurationName"); | ||
} | ||
} |