Dispatch() 공개 메소드

Dispatches the ResponseMessage (this) to the supplied INetworkMessageReceiver.
Throws if either parameters are null.
public Dispatch ( INetworkMessageReceiver receiver, IMessageParameters parameters ) : void
receiver INetworkMessageReceiver The target .
parameters IMessageParameters The of the .
리턴 void
예제 #1
0
        public static void Test_Dispatch_Null_Parameters()
        {
            //arrange
            Mock<PacketPayload> packet = new Mock<PacketPayload>(MockBehavior.Strict);
            ResponseMessage message = new ResponseMessage(packet.Object);
            Mock<INetworkMessageReceiver> receiever = new Mock<INetworkMessageReceiver>(MockBehavior.Strict);

            //Sets up the method that should be called so it doesn't throw.
            //Also rigs it up so that the two mocks above should be the values provided.
            receiever.Setup((actual) => actual.OnNetworkMessageReceive(message, null));

            //assert
            //Exception should be thrown for null.
            Assert.Throws<ArgumentNullException>(() => message.Dispatch(receiever.Object, null));
        }
예제 #2
0
        public static void Test_Dispatch()
        {
            //arrange
            Mock<PacketPayload> packet = new Mock<PacketPayload>(MockBehavior.Strict);
            ResponseMessage message = new ResponseMessage(packet.Object);
            Mock<IMessageParameters> parameters = new Mock<IMessageParameters>(MockBehavior.Strict);
            Mock<INetworkMessageReceiver> receiever = new Mock<INetworkMessageReceiver>(MockBehavior.Strict);

            //Sets up the method that should be called so it doesn't throw.
            //Also rigs it up so that the two mocks above should be the values provided.
            receiever.Setup((actual) => actual.OnNetworkMessageReceive(message, parameters.Object));

            //act
            message.Dispatch(receiever.Object, parameters.Object);

            //asset
            receiever.Verify((actual) => actual.OnNetworkMessageReceive(message, parameters.Object));
        }
예제 #3
0
        public static void Test_Dispatch_Null_Receiver()
        {
            //arrange
            Mock<PacketPayload> packet = new Mock<PacketPayload>(MockBehavior.Strict);
            ResponseMessage message = new ResponseMessage(packet.Object);
            Mock<IMessageParameters> parameters = new Mock<IMessageParameters>(MockBehavior.Strict);

            //assert
            //Exception should be thrown for null.
            Assert.Throws<ArgumentNullException>(() => message.Dispatch(null, parameters.Object));
        }