Dispatch() public méthode

Dispatches the RequestMessage (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 .
Résultat void
        public static void Test_Dispatch_Null_Parameters()
        {
            //arrange
            Mock<PacketPayload> packet = new Mock<PacketPayload>(MockBehavior.Strict);
            RequestMessage message = new RequestMessage(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));
        }
        public static void Test_Dispatch()
        {
            //arrange
            Mock<PacketPayload> packet = new Mock<PacketPayload>(MockBehavior.Strict);
            RequestMessage message = new RequestMessage(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));
        }
        public static void Test_Dispatch_Null_Receiver()
        {
            //arrange
            Mock<PacketPayload> packet = new Mock<PacketPayload>(MockBehavior.Strict);
            RequestMessage message = new RequestMessage(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));
        }