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

            var behaviouralState1 = fsm.AddWithBehaviours(1);

            Assert.IsTrue(fsm.ContainsState(1));
            Assert.IsTrue(fsm.GetStateById(1) == behaviouralState1);

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

            var behaviouralState2 = fsm.AddWithBehaviours(2, stateBehaviour1, stateBehaviour2);

            Assert.IsTrue(fsm.ContainsState(2));
            Assert.IsTrue(fsm.GetStateById(2) == behaviouralState2);
            Assert.IsTrue(fsm.ContainsBehaviour(stateBehaviour1));
            Assert.IsTrue(fsm.ContainsBehaviour(stateBehaviour2));
            Assert.IsTrue(fsm.BehaviourCount() == 2);
            Assert.IsTrue(fsm.BehaviourCountOf(2) == 2);
        }