public void Do_Nothing_If_User_Tries_To_Add_The_Same_Behaviour_On_The_Same_State_Twice() { var fsm = new HierarchicalStateMachine <int, int>(); var stateBehaviour1 = Substitute.For <IStateBehaviour>(); fsm.AddWithBehaviours(1); fsm.AddBehaviourTo(1, stateBehaviour1); Assert.DoesNotThrow(() => fsm.AddBehaviourTo(1, stateBehaviour1)); Assert.IsTrue(fsm.BehaviourCount() == 1); }
public void Add_Behaviour_To_Behavioural_States() { var fsm = new HierarchicalStateMachine <int, int>(); var stateBehaviour1 = Substitute.For <IStateBehaviour>(); fsm.AddWithBehaviours(1); fsm.AddBehaviourTo(1, stateBehaviour1); Assert.IsTrue(fsm.ContainsBehaviour(stateBehaviour1)); }
public void Throw_An_Exception_If_User_Tries_To_Add_A_Null_Behaviour() { var fsm = new HierarchicalStateMachine <int, int>(); var stateBehaviour1 = Substitute.For <IStateBehaviour>(); Assert.Throws <ArgumentNullException>(() => fsm.AddWithBehaviours(1, stateBehaviour1, null)); fsm.AddWithBehaviours(1); Assert.Throws <ArgumentNullException>(() => fsm.AddBehaviourTo(1, null)); Assert.Throws <ArgumentNullException>(() => fsm.AddBehavioursTo(1, stateBehaviour1, null)); }