Beispiel #1
0
        public void T402_ChangeState()
        {
            TcoStateTest ts = tc._tcoObjectTest_A._tcoStateTest_A;

            short initState;
            short newState;
            short ccc = ts._onStateChangeCounter.Synchron;                                              //Store the actual value of the calls of the method OnStateChange().

            ts.ReadOutState();

            initState = ts._myState.Synchron;                                                           //Store the previous state of the ts
            newState  = TestHelpers.RandomNumber((short)(initState + 1), (short)(5 * (initState + 1))); //Generate new random value of the new state.
            Assert.AreNotEqual(initState, newState);                                                    //New state should be different as the initial state.

            tc.ContextOpen();

            ts.TriggerChangeState(newState);                                                            //Change state of the ts to the new value newState.
            ts.ReadOutState();

            tc.ContextClose();

            Assert.AreEqual(newState, ts._myState.Synchron);                                            //Check if the state of the ts has been changed to the newState.
            Assert.AreEqual(ccc + 1, ts._onStateChangeCounter.Synchron);                                //OnStateChange() method should be called just once, as the only one change of the state has been performed on the ts.
            Assert.AreEqual("My state has been change from " + initState.ToString()                     //Check if overiden method OnStateChange() generate expected message.
                            + " to the new state " + newState.ToString() + ".", ts.GetMessage());
        }
Beispiel #2
0
        public void T403_OnStateChange()
        {
            TcoStateTest ts      = tc._tcoObjectTest_A._tcoStateTest_A;
            string       message = TestHelpers.RandomString(20);
            short        initState;
            short        newState;
            short        ccc = ts._onStateChangeCounter.Synchron;                                       //Store the actual value of the calls of the method OnStateChange().

            tc.SingleCycleRun(() =>
            {
                ts.PostMessage(message);                                                                //Force test instance to post randomly generated message.
            });

            Assert.AreEqual(message, ts.GetMessage());                                                  //Check if the randomly generated message has been appeared in mime.

            ts.ReadOutState();

            initState = ts._myState.Synchron;                                                           //Store the previous state of the ts
            newState  = TestHelpers.RandomNumber((short)(initState + 1), (short)(5 * (initState + 1))); //Generate new random value of the new state.
            Assert.AreNotEqual(initState, newState);                                                    //New state should be different as the initial state.

            tc.SingleCycleRun(() =>
            {
                ts.TriggerChangeState(initState);                                                       //Change state initiated to the same value as the actual state was before. From initState to initState.
            });
            ts.ReadOutState();

            Assert.AreEqual(initState, ts._myState.Synchron);                                           //State of the ts should stay the same.
            Assert.AreEqual(ccc, ts._onStateChangeCounter.Synchron);                                    //OnStateChange() method should not call, as there was no real change of the state of the ts.
            Assert.AreEqual(message, ts.GetMessage());                                                  //Message should stay the same, as there was no real change of the state of the ts and therefor no OnStateChange() method should be performed.

            tc.SingleCycleRun(() =>
            {
                ts.TriggerChangeState(newState);                                                        //Change state initiated to the different value as before. From initState to newState.
            });
            ts.ReadOutState();

            Assert.AreEqual(newState, ts._myState.Synchron);                                            //Check if the state of the ts has been changed from initState to newState.
            Assert.AreEqual(ccc + 1, ts._onStateChangeCounter.Synchron);                                //OnStateChange() method should be called just once, as the only one change of the state has been performed on the ts.
            Assert.AreEqual("My state has been change from " + initState.ToString()                     //Check if overiden method OnStateChange() generate expected message and overwrite the message randomly generated.
                            + " to the new state " + newState.ToString() + ".", ts.GetMessage());
        }
Beispiel #3
0
        public void T401_StateMessage()
        {
            TcoStateTest ts      = tc._tcoObjectTest_A._tcoStateTest_A;
            string       message = TestHelpers.RandomString(20);

            tc.ContextOpen();
            ts.PostMessage(message);                                                                    //Force the error message to the task instence
            tc.ContextClose();

            Assert.AreEqual(message, ts.GetMessage());                                                  //Check if message apears in the mime.
        }