-
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.
- Loading branch information
Showing
7 changed files
with
72 additions
and
37 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
1 change: 0 additions & 1 deletion
1
test/Fraktalio.FModel.Tests/Examples/Numbers/Even/EvenNumberDecider.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
20 changes: 4 additions & 16 deletions
20
test/Fraktalio.FModel.Tests/Examples/Numbers/NumberState.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 |
---|---|---|
@@ -1,19 +1,7 @@ | ||
namespace Fraktalio.FModel.Tests.Examples.Numbers.States; | ||
namespace Fraktalio.FModel.Tests.Examples.Numbers; | ||
|
||
public abstract class NumberState | ||
{ | ||
public abstract Description Description { get; } | ||
public abstract Number Value { get; } | ||
} | ||
public abstract record NumberState(Description Description, Number Value); | ||
|
||
public sealed class EvenNumberState(Description description, Number value) : NumberState | ||
{ | ||
public override Description Description { get; } = description; | ||
public override Number Value { get; } = value; | ||
} | ||
public sealed record EvenNumberState(Description Description, Number Value) : NumberState(Description, Value); | ||
|
||
public sealed class OddNumberState(Description description, Number value) : NumberState | ||
{ | ||
public override Description Description { get; } = description; | ||
public override Number Value { get; } = value; | ||
} | ||
public sealed record OddNumberState(Description Description, Number Value) : NumberState(Description, Value); |
1 change: 0 additions & 1 deletion
1
test/Fraktalio.FModel.Tests/Examples/Numbers/Odd/OddNumberDecider.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
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,49 @@ | ||
using Fraktalio.FModel.Tests.Examples.Numbers; | ||
using Fraktalio.FModel.Tests.Examples.Numbers.Even; | ||
using Fraktalio.FModel.Tests.Examples.Numbers.Odd; | ||
using EvenNumberCommand = Fraktalio.FModel.Tests.Examples.Numbers.NumberCommand.EvenNumberCommand; | ||
using OddNumberCommand = Fraktalio.FModel.Tests.Examples.Numbers.NumberCommand.OddNumberCommand; | ||
|
||
namespace Fraktalio.FModel.Tests; | ||
|
||
[Category("unit")] | ||
public class StateStoredDeciderTest | ||
{ | ||
private readonly EvenNumberDecider _evenNumberDecider = new(); | ||
private readonly OddNumberDecider _oddNumberDecider = new(); | ||
|
||
[Test] | ||
public void GivenEmptyState_AddEvenNumber() => | ||
_evenNumberDecider | ||
.GivenState(null, | ||
() => new EvenNumberCommand.AddEvenNumber(Description.Create("2"), Number.Create(2))) | ||
.ThenState(new EvenNumberState(Description.Create("Initial state + 2"), Number.Create(2))); | ||
|
||
[Test] | ||
public void GivenState_AddEvenNumber() => | ||
_evenNumberDecider | ||
.GivenState(new EvenNumberState(Description.Create("2"), Number.Create(2)), | ||
() => new EvenNumberCommand.AddEvenNumber(Description.Create("4"), Number.Create(4))) | ||
.ThenState(new EvenNumberState(Description.Create("2 + 4"), Number.Create(6))); | ||
|
||
[Test] | ||
public void GivenState_SubtractEvenNumber() => | ||
_evenNumberDecider | ||
.GivenState(new EvenNumberState(Description.Create("8"), Number.Create(8)), | ||
() => new EvenNumberCommand.SubtractEvenNumber(Description.Create("2"), Number.Create(2))) | ||
.ThenState(new EvenNumberState(Description.Create("8 - 2"), Number.Create(6))); | ||
|
||
[Test] | ||
public void GivenState_AddOddNumber() => | ||
_oddNumberDecider | ||
.GivenState(new OddNumberState(Description.Create("3"), Number.Create(3)), | ||
() => new OddNumberCommand.AddOddNumber(Description.Create("1"), Number.Create(1))) | ||
.ThenState(new OddNumberState(Description.Create("3 + 1"), Number.Create(4))); | ||
|
||
[Test] | ||
public void GivenState_SubtractOddNumber() => | ||
_oddNumberDecider | ||
.GivenState(new OddNumberState(Description.Create("3"), Number.Create(3)), | ||
() => new OddNumberCommand.SubtractOddNumber(Description.Create("1"), Number.Create(1))) | ||
.ThenState(new OddNumberState(Description.Create("3 - 1"), Number.Create(2))); | ||
} |