public async void Execute_changes_state_for_superState()
        {
            const SaleState startState = SaleState.Open;
            const SaleState endState   = SaleState.Complete;
            var             sale       = new Sale(saleID: 66)
            {
                State = SaleState.ChangeDue
            };
            var stateMachine = GetStateMachine();

            var openStateConfig = stateMachine.ConfigureState(SaleState.Open);

            stateMachine.ConfigureState(SaleState.ChangeDue)
            .MakeSubStateOf(openStateConfig);

            var sut = new StateTransitionAutoForwardAsync <Sale, SaleState, SaleEvent>(
                stateMachine
                , triggerState: startState
                , toState: endState
                , conditionAsync: (_, cancelToke) => Task.FromResult(true)
                , name: "test"
                , priority: 1);
            var previousResult = GetDummyResult();

            previousResult.CurrentState = SaleState.ChangeDue;

            var result = await sut.ExecuteAsync(new ExecutionParameters <Sale, SaleEvent>(SaleEvent.Pay, sale), previousResult);

            Assert.True(result.WasTransitioned);
            Assert.Equal(endState, sale.State);
            Assert.Equal(endState, result.CurrentState);
            Assert.Equal(SaleState.ChangeDue, result.PreviousState);
            Assert.Equal(startState, result.StartingState);
            Assert.True(result.TransitionDefined);
        }
        public async void Execute_does_not_change_state_if_currentResult_is_null()
        {
            const SaleState startState = SaleState.Open;
            const SaleState endState   = SaleState.Complete;
            var             sale       = new Sale(saleID: 66)
            {
                State = startState
            };

            var sut = new StateTransitionAutoForwardAsync <Sale, SaleState, SaleEvent>(
                getStateMachine()
                , triggerState: startState
                , toState: endState
                , conditionAsync: (_, cancelToken) => Task.FromResult(false)
                , name: "test"
                , priority: 1);

            var result = await sut.ExecuteAsync(new ExecutionParameters <Sale, SaleEvent>(SaleEvent.Pay, sale), currentResult : null);

            Assert.Equal(startState, sale.State);
            Assert.False(result.ConditionMet);
            Assert.False(result.WasTransitioned);
            Assert.False(result.WasCancelled);
            Assert.True(result.TransitionDefined);
            Assert.Equal(startState, result.StartingState);
            Assert.Equal(startState, result.PreviousState);
            Assert.Equal(startState, result.CurrentState);
        }
        public async void Execute_changes_state_if_condition_met()
        {
            const SaleState startState = SaleState.Open;
            const SaleState endState   = SaleState.Complete;
            var             sale       = new Sale(saleID: 66)
            {
                State = startState
            };

            var sut = new StateTransitionAutoForwardAsync <Sale, SaleState, SaleEvent>(
                GetStateMachine()
                , triggerState: startState
                , toState: endState
                , conditionAsync: (sale1, token) => Task.FromResult(true)
                , name: "test"
                , priority: 1);

            var result = await sut.ExecuteAsync(new ExecutionParameters <Sale, SaleEvent>(SaleEvent.Pay, sale), GetDummyResult());

            Assert.True(result.WasTransitioned);
            Assert.Equal(endState, sale.State);
            Assert.Equal(endState, result.CurrentState);
            Assert.Equal(startState, result.PreviousState);
            Assert.Equal(startState, result.StartingState);
            Assert.True(result.TransitionDefined);
        }