public void ShouldNotBeInAnyStateInitially()
 {
     var stateMachine = new StateMachine("test-state");
     foreach (string state in states)
     {
         Assert.IsFalse(stateMachine.Is(state).IsActive(), "state machine should not be in any state");
         Assert.IsTrue(stateMachine.IsNot(state).IsActive(), "state machine should not be in any state");
     }
 }
        public void DescribesNameAndItsCurrentState()
        {
            var stateMachine = new StateMachine("fruitness");

            Assert.That(StringDescription.Describe(stateMachine),
                        NUnit.Framework.Is.EqualTo(string.Format("fruitness has no current state")));
            stateMachine.Is("apple").Activate();

            Assert.That(StringDescription.Describe(stateMachine),
                        NUnit.Framework.Is.EqualTo(string.Format("fruitness is apple")));
        }
 public void CanEnterAState()
 {
     HashSet<string> otherStates = Except("state1", states);
     var stateMachine = new StateMachine("test-state");
     stateMachine.Is("state1").Activate();
     Assert.That(stateMachine.Is("state1").IsActive(), "should be active");
     foreach (string otherState in otherStates)
     {
         Assert.IsFalse(stateMachine.Is(otherState).IsActive(), "should not be in other state");
         Assert.That(stateMachine.IsNot(otherState).IsActive(), "should not be in other state");
     }
 }
Example #4
0
 public static State IsIn(string s, StateMachine stateMachine)
 {
     return new State(stateMachine, s);
 }
Example #5
0
 public State(StateMachine stateMachine, string state)
 {
     this.stateMachine = stateMachine;
     this.state = state;
 }