@@ -11,17 +11,17 @@ final class StateMachineTests: XCTestCase, StateMachineBuilder {
1111
1212 enum State : StateMachineHashable {
1313
14- case stateOne, stateTwo
14+ case stateOne, stateTwo, stateThree
1515 }
1616
1717 enum Event : StateMachineHashable {
1818
19- case eventOne, eventTwo
19+ case eventOne, eventTwo, eventThree
2020 }
2121
22- enum SideEffect {
22+ enum SideEffect : Equatable {
2323
24- case commandOne, commandTwo, commandThree
24+ case commandOne, commandTwo, commandThree, commandFour ( Int )
2525 }
2626
2727 typealias TestStateMachine = StateMachine < State , Event , SideEffect >
@@ -33,7 +33,7 @@ final class StateMachineTests: XCTestCase, StateMachineBuilder {
3333 initialState ( _state)
3434 state ( . stateOne) {
3535 on ( . eventOne) {
36- dontTransition ( emit: . commandOne)
36+ dontTransition ( emit: . commandOne, . commandTwo )
3737 }
3838 on ( . eventTwo) {
3939 transition ( to: . stateTwo, emit: . commandTwo)
@@ -43,7 +43,11 @@ final class StateMachineTests: XCTestCase, StateMachineBuilder {
4343 on ( . eventTwo) {
4444 dontTransition ( emit: . commandThree)
4545 }
46+ on ( . eventThree) { _, event in
47+ transition ( to: . stateThree, emit: . commandFour( try event. string ( ) ) )
48+ }
4649 }
50+ state ( . stateThree)
4751 }
4852 }
4953
@@ -66,7 +70,7 @@ final class StateMachineTests: XCTestCase, StateMachineBuilder {
6670 expect ( transition) . to ( equal ( ValidTransition ( fromState: . stateOne,
6771 event: . eventOne,
6872 toState: . stateOne,
69- sideEffects: [ . commandOne] ) ) )
73+ sideEffects: [ . commandOne, . commandTwo ] ) ) )
7074 }
7175
7276 func testTransition( ) throws {
@@ -131,7 +135,7 @@ final class StateMachineTests: XCTestCase, StateMachineBuilder {
131135 . success( ValidTransition ( fromState: . stateOne,
132136 event: . eventOne,
133137 toState: . stateOne,
134- sideEffects: [ . commandOne] ) ) ,
138+ sideEffects: [ . commandOne, . commandTwo ] ) ) ,
135139 . success( ValidTransition ( fromState: . stateOne,
136140 event: . eventTwo,
137141 toState: . stateTwo,
@@ -191,6 +195,14 @@ final class StateMachineTests: XCTestCase, StateMachineBuilder {
191195 // Then
192196 expect ( error) . to ( equal ( . recursionDetected) )
193197 }
198+
199+ func testGettingNonExistingValue( ) throws {
200+ // Given
201+ let stateMachine : TestStateMachine = givenState ( is: . stateTwo)
202+
203+ // Then
204+ XCTAssertThrowsError ( try stateMachine. transition ( . eventThree) )
205+ }
194206}
195207
196208final class Logger {
0 commit comments