Example #1
0
        public void Remove_Behaviours_From_Behavioural_States()
        {
            var fsm = new HierarchicalStateMachine <int, int>();

            var stateBehaviour1 = Substitute.For <IStateBehaviour>();
            var stateBehaviour2 = Substitute.For <IStateBehaviour>();

            fsm.AddWithBehaviours(1, stateBehaviour1, stateBehaviour2);

            fsm.RemoveBehaviourFrom(1, stateBehaviour1);

            Assert.IsTrue(fsm.BehaviourCount() == 1);
            Assert.IsTrue(fsm.BehaviourCountOf(1) == 1);
            Assert.IsFalse(fsm.ContainsBehaviour(stateBehaviour1));
            Assert.IsFalse(fsm.ContainsBehaviourOn(1, stateBehaviour1));
            Assert.IsTrue(fsm.ContainsBehaviour(stateBehaviour2));
            Assert.IsTrue(fsm.ContainsBehaviourOn(1, stateBehaviour2));

            fsm.RemoveBehaviourFrom(1, stateBehaviour2);

            Assert.IsTrue(fsm.BehaviourCount() == 0);
            Assert.IsTrue(fsm.BehaviourCountOf(1) == 0);
            Assert.IsFalse(fsm.ContainsBehaviour(stateBehaviour2));
            Assert.IsFalse(fsm.ContainsBehaviourOn(1, stateBehaviour2));
        }
Example #2
0
        public void Throw_An_Exception_If_User_Asks_If_Contains_Behaviour_With_A_Null_Behaviour()
        {
            var fsm = new HierarchicalStateMachine <int, int>();

            Assert.Throws <ArgumentNullException>(() => fsm.ContainsBehaviour(null));
            Assert.Throws <ArgumentNullException>(() => fsm.ContainsBehaviourOn(1, null));
        }