public void Let_Remove_States_When_OnBeforeStateChanges_Event_Is_Being_Executed_Except_From_The_Involved_States() { _stateMachine.AddState(_stateId1, _stateObject1); _stateMachine.AddState(_stateId2, _stateObject2); _stateMachine.AddState(_stateId3, _stateObject3); var transition = NewTransition(_stateId1, _trigger1, _stateId2); _stateMachine.AddTransition(transition); _onBeforeStateChangesSubscriptor1.When(obj => obj.Invoke(Arg.Any <TState>(), Arg.Any <TTrigger>(), Arg.Any <TState>())) .Do(_ => { _stateMachine.RemoveState(_stateId3); _stateMachine.RemoveState(_stateId1); }); _stateMachine.OnBeforeStateChanges += _onBeforeStateChangesSubscriptor1; _stateMachine.Start(); var exception = Assert.Throws <ProtectedStateException>(() => _stateMachine.Trigger(_trigger1)); Assert.That(exception.StateId.Equals(_stateId1), "Exception was thrown when tried to remove stateId1 (previous state)"); }