Exemplo n.º 1
0
        public async void SendAsync_SetStateMessage_SerializesMessageCorrectly()
        {
            // Arrange
            var message = new SetStateMessage("context", new SetStatePayload(1));

            // Act
            string result = await SendAndReceiveMessageAsync(message);

            // Assert
            Approvals.Verify(result);
        }
        /// <summary>
        /// The main interface for communicating between behaviours.  Using polymorphism, we
        /// define a bunch of different messages deriving from BehaviourMessage.  Each behaviour
        /// can then check for particular upcasted messahe types, and either grab some data
        /// from it (set message) or store some data in it (get message).
        /// </summary>
        /// <param name="msg">The message being communicated to the behaviour.</param>
        public override void OnMessage(ref BehaviourMessage msg)
        {
            if (msg is SetStateMessage)
            {
                SetStateMessage temp = (SetStateMessage)msg;

                AdvanceToState(temp.mNextState_In);
            }

            // Pass the message down to the currently running state.
            mCurrentState.OnMessage(ref msg);
        }