public void TriggerTransition_InvalidTransition_ExceptionThrown()
        {
            //arrange
            var bug = new Bug("bug1", _stateMachine);

            //act/assert
            Assert.Throws<InvalidStateTransitionException<BugState>>(() => bug.Resolve());
        }
        public void TriggerTransition_TwoSuccessiveValidTransitions_NoExceptionThrown()
        {
            //arrange
            var bug = new Bug("bug1", _stateMachine);

            //act/assert
            Assert.DoesNotThrow(() => bug.Assign("*****@*****.**").Defer());
            Assert.That(bug.CurrentState == new BugState.Deferred());
        }
        public void TriggerTransition_UnexpectedDtoSupplied_NoExceptionThrown()
        {
            //arrange
            var bug = new Bug("bug1", _stateMachine);
            dynamic args = new ExpandoObject();
            args.Blah = "blah";

            //act/assert
            Assert.DoesNotThrow(() => bug.TriggerTransition(bug, new BugState.Open(), args));
        }
        public void TriggerTransition_IdentityTransition_NoExceptionThrown()
        {
            //arrange
            var bug = new Bug("bug1", _stateMachine);

            //act/assert
            Assert.That(bug.CurrentState == new BugState.Open());
            Assert.DoesNotThrow(() => bug.Open());
            Assert.That(bug.CurrentState == new BugState.Open());
        }
        public void Setup()
        {
            _transitions = new IStateTransition<BugState, TransitionActionStatus>[]
                               {
                                   new BugTransition.Open(),
                                   new BugTransition.Assign(new BugTransitionAction.Assign()),
                                   new BugTransition.Defer(new BugTransitionAction.Defer()),
                                   new BugTransition.Resolve(new BugTransitionAction.Resolve()),
                                   new BugTransition.Close(new BugTransitionAction.Close()),
                               };

            _stateMachine = new StateMachine<BugState, TransitionActionStatus>("state machine name",
                                                                               _transitions,
                                                                               initialState: new BugState.Open());
            _bug = new Bug("bug1");
        }
        public void TriggerTransition_ValidTransitionWithArgument_ArgumentSetInTargetObjectCorrectly()
        {
            //arrange
            var bug = new Bug("bug1", _stateMachine);
            const string assigneeEmail = "*****@*****.**";

            //act/assert
            bug.Assign(assigneeEmail);

            Assert.That(bug.AssigneeEmail == assigneeEmail);
        }
        public void TriggerTransition_ValidTransition_NoExceptionThrown()
        {
            //arrange
            var bug = new Bug("bug1", _stateMachine);
            dynamic args = new ExpandoObject();
            args.AssigneeEmail = "*****@*****.**";

            //act/assert
            Assert.DoesNotThrow(() => bug.TriggerTransition(bug, new BugState.Assigned(), args));
        }
Exemple #8
0
 public BugStateful(Bug bug, IStateMachine <BugState, TransitionActionStatus> stateMachine = null)
     : base(stateMachine ?? new NullStateMachine <BugState, TransitionActionStatus>())
 {
     Bug = bug;
 }