Appccelerate.StateMachine.Machine.ExceptionCasesTest.ExceptionThrowingGuard C# (CSharp) Method

ExceptionThrowingGuard() private method

private ExceptionThrowingGuard ( ) : void
return void
        public void ExceptionThrowingGuard()
        {
            var eventArguments = new object[] { 1, 2, "test" };
            Exception exception = new Exception();
            
            this.testee.In(StateMachine.States.A)
                .On(StateMachine.Events.B)
                    .If(() => { throw exception; }).Goto(StateMachine.States.B);

            bool transitionDeclined = false;
            this.testee.TransitionDeclined += (sender, e) => transitionDeclined = true;

            this.testee.Initialize(StateMachine.States.A);
            this.testee.EnterInitialState();

            this.testee.Fire(StateMachine.Events.B, eventArguments);

            this.AssertException(StateMachine.States.A, StateMachine.Events.B, eventArguments, exception);
            Assert.Equal(StateMachine.States.A, this.testee.CurrentStateId);
            Assert.True(transitionDeclined, "transition was not declined.");
        }