Pop() public method

Removes a routing key from the message. This key indicates where this message should be forwared to.
public Pop ( ) : int?
return int?
		public static void Test_Serialized_Stack_Results_In_Same_Order()
		{
			ProtobufnetRegistry registry = new ProtobufnetRegistry();

			registry.Register(typeof(NetworkMessage));
			registry.Register(typeof(RequestMessage));
			registry.Register(typeof(EventMessage));
			registry.Register(typeof(ResponseMessage));


			RequestMessage message = new RequestMessage(new StatusChangePayload(Common.NetStatus.Connected));
			message.Push(1);
			message.Push(2);
			message.Push(3);
			message.Push(4);

			ProtobufnetSerializerStrategy serializer = new ProtobufnetSerializerStrategy();

			Assert.NotNull((new ProtobufnetDeserializerStrategy()).Deserialize<RequestMessage>(serializer.Serialize(message as NetworkMessage)));
			RequestMessage deserializedMessage = (new ProtobufnetDeserializerStrategy()).Deserialize<RequestMessage>(serializer.Serialize(message as NetworkMessage));

			//check that the stack is in the same order
			Assert.AreEqual(message.Pop(), deserializedMessage.Pop());
			Assert.AreEqual(message.Pop(), deserializedMessage.Pop());
			Assert.AreEqual(message.Pop(), deserializedMessage.Pop());
			Assert.AreEqual(message.Pop(), deserializedMessage.Pop());
		}
		public static void Test_Probuf_Serializes_Message_And_Serializes_Message_With_Payload()
		{
			ProtobufnetRegistry registry = new ProtobufnetRegistry();

			registry.Register(typeof(NetworkMessage));
			registry.Register(typeof(RequestMessage));
			registry.Register(typeof(RequestMessage));
			registry.Register(typeof(EventMessage));
			registry.Register(typeof(ResponseMessage));
			registry.Register(typeof(StatusMessage));
			registry.Register(typeof(NetSendable<>));
			registry.Register(typeof(NetSendable<PacketPayload>));
			registry.Register(typeof(TestPayload));




			RequestMessage message = new RequestMessage(new TestPayload());
			message.Payload.Serialize(new ProtobufnetSerializerStrategy());
			message.Payload.Deserialize(new ProtobufnetDeserializerStrategy());
			Assert.NotNull(message.Payload.Data);
			message.Payload.Serialize(new ProtobufnetSerializerStrategy());
			message.Push(1);
			message.Pop();

			ProtobufnetSerializerStrategy serializer = new ProtobufnetSerializerStrategy();

			Assert.NotNull((new ProtobufnetDeserializerStrategy()).Deserialize<NetworkMessage>(serializer.Serialize(message as NetworkMessage)).Payload);
		}
		public static void Test_Serialized_Stack_Empty_Results_In_Not_Throw()
		{
			ProtobufnetRegistry registry = new ProtobufnetRegistry();

			registry.Register(typeof(NetworkMessage));
			registry.Register(typeof(RequestMessage));
			registry.Register(typeof(EventMessage));
			registry.Register(typeof(ResponseMessage));


			RequestMessage message = new RequestMessage(new StatusChangePayload(Common.NetStatus.Connected));
			message.Push(1);
			message.Pop();

			ProtobufnetSerializerStrategy serializer = new ProtobufnetSerializerStrategy();

			Assert.DoesNotThrow(() => (new ProtobufnetDeserializerStrategy()).Deserialize<RequestMessage>(serializer.Serialize(message as NetworkMessage)));
		}
Esempio n. 4
0
        public static void Test_Event_Message_Routing_Stack_Has_Pushed_Values()
        {
            //arrange
            Mock<PacketPayload> packet = new Mock<PacketPayload>(MockBehavior.Strict);
            RequestMessage message = new RequestMessage(packet.Object);

            //act
            message.Push(5);
            message.Push(4);
            message.Push(3);

            //assert
            Assert.NotNull(message.Peek());
            Assert.True(message.isMessageRoutable);

            Assert.AreEqual(3, message.Pop());
            Assert.AreEqual(4, message.Pop());
            Assert.AreEqual(5, message.Pop());

            Assert.IsNull(message.Peek());
            Assert.IsFalse(message.isMessageRoutable); //shouldn't be able to rout
        }