add failing unit test.
MODIFY
WalletWasabi.Tests/UnitTests/StateMachineTests.cs
WalletWasabi.Tests/UnitTests/StateMachineTests.cs
@@ -30,7 +30,8 @@ public class StateMachineTests
{
Playing,
Paused,
- PausedChild
+ PausedChild,
+ PausedChild2
}
[Fact]
@@ -333,4 +334,37 @@ public class StateMachineTests
Assert.Equal(1, entryCallCount);
}
+
+ [Fact]
+ public void Is_In_State_Works_With_Child_Child_States()
+ {
+ StateMachine<JukeBoxState, JukeBoxTrigger> sut =
+ new StateMachine<JukeBoxState, JukeBoxTrigger>(JukeBoxState.Paused);
+
+ int entryCallCount = 0;
+
+ sut.Configure(JukeBoxState.Paused)
+ .Permit(JukeBoxTrigger.Pause, JukeBoxState.PausedChild);
+
+ sut.Configure(JukeBoxState.PausedChild)
+ .SubstateOf(JukeBoxState.Paused)
+ .Permit(JukeBoxTrigger.Pause, JukeBoxState.PausedChild2)
+ .OnEntry(() => entryCallCount++);
+
+ sut.Configure(JukeBoxState.PausedChild2)
+ .SubstateOf(JukeBoxState.PausedChild)
+ .OnEntry(() => entryCallCount++);
+
+ sut.Start();
+
+ sut.Fire(JukeBoxTrigger.Pause);
+
+ Assert.Equal(1, entryCallCount);
+ Assert.True(sut.IsInState(JukeBoxState.Paused));
+
+ sut.Fire(JukeBoxTrigger.Pause);
+
+ Assert.Equal(2, entryCallCount);
+ Assert.True(sut.IsInState(JukeBoxState.Paused));
+ }
}
\ No newline at end of file

add failing unit test.