Beispiel #1
0
        public virtual void Test()
        {
            Collection4 expected = new Collection4(new object[] { "PING", true, 42 });

            MessagingTestCaseBase.MessageCollector recipient = new MessagingTestCaseBase.MessageCollector
                                                                   ();
            IObjectServer server = OpenServerWith(recipient);

            try
            {
                IObjectContainer client = OpenClient("client", server);
                try
                {
                    IMessageSender sender = MessageSender(client);
                    SendAll(expected, sender);
                }
                finally
                {
                    client.Close();
                }
            }
            finally
            {
                server.Close();
            }
            Assert.AreEqual(expected.ToString(), recipient.messages.ToString());
        }
		public virtual void Test()
		{
			Collection4 expected = new Collection4(new object[] { "PING", true, 42 });
			MessagingTestCaseBase.MessageCollector recipient = new MessagingTestCaseBase.MessageCollector
				();
			IObjectServer server = OpenServerWith(recipient);
			try
			{
				IObjectContainer client = OpenClient("client", server);
				try
				{
					IMessageSender sender = MessageSender(client);
					SendAll(expected, sender);
				}
				finally
				{
					client.Close();
				}
			}
			finally
			{
				server.Close();
			}
			Assert.AreEqual(expected.ToString(), recipient.messages.ToString());
		}
Beispiel #3
0
        private void AssertReplyBehavior(ServerToClientTestCase.IClientWaitLogic clientWaitLogic
                                         )
        {
            MessagingTestCaseBase.MessageCollector collector1 = new MessagingTestCaseBase.MessageCollector
                                                                    ();
            MessagingTestCaseBase.MessageCollector collector2 = new MessagingTestCaseBase.MessageCollector
                                                                    ();
            IObjectServer server = OpenServerWith(new ServerToClientTestCase.AutoReplyRecipient
                                                      ());

            try
            {
                IObjectContainer client1 = OpenClient("client1", server);
                try
                {
                    SetMessageRecipient(client1, collector1);
                    IMessageSender   sender1 = MessageSender(client1);
                    IObjectContainer client2 = OpenClient("client2", server);
                    try
                    {
                        SetMessageRecipient(client2, collector2);
                        IMessageSender sender2 = MessageSender(client2);
                        SendEvenOddMessages(sender1, sender2);
                        clientWaitLogic.Wait(client1, client2);
                        try
                        {
                            // Give the message processor thread time to dispatch the message.
                            Thread.Sleep(100);
                        }
                        catch (Exception e)
                        {
                            Sharpen.Runtime.PrintStackTrace(e);
                        }
                        Assert.AreEqual("[reply: 0, reply: 2, reply: 4, reply: 6, reply: 8]", collector1.
                                        messages.ToString());
                        Assert.AreEqual("[reply: 1, reply: 3, reply: 5, reply: 7, reply: 9]", collector2.
                                        messages.ToString());
                    }
                    finally
                    {
                        client2.Close();
                    }
                }
                finally
                {
                    client1.Close();
                }
            }
            finally
            {
                server.Close();
            }
        }
		private void AssertReplyBehavior(ServerToClientTestCase.IClientWaitLogic clientWaitLogic
			)
		{
			MessagingTestCaseBase.MessageCollector collector1 = new MessagingTestCaseBase.MessageCollector
				();
			MessagingTestCaseBase.MessageCollector collector2 = new MessagingTestCaseBase.MessageCollector
				();
			IObjectServer server = OpenServerWith(new ServerToClientTestCase.AutoReplyRecipient
				());
			try
			{
				IObjectContainer client1 = OpenClient("client1", server);
				try
				{
					SetMessageRecipient(client1, collector1);
					IMessageSender sender1 = MessageSender(client1);
					IObjectContainer client2 = OpenClient("client2", server);
					try
					{
						SetMessageRecipient(client2, collector2);
						IMessageSender sender2 = MessageSender(client2);
						SendEvenOddMessages(sender1, sender2);
						clientWaitLogic.Wait(client1, client2);
						try
						{
							// Give the message processor thread time to dispatch the message.
							Thread.Sleep(100);
						}
						catch (Exception e)
						{
							Sharpen.Runtime.PrintStackTrace(e);
						}
						Assert.AreEqual("[reply: 0, reply: 2, reply: 4, reply: 6, reply: 8]", collector1.
							messages.ToString());
						Assert.AreEqual("[reply: 1, reply: 3, reply: 5, reply: 7, reply: 9]", collector2.
							messages.ToString());
					}
					finally
					{
						client2.Close();
					}
				}
				finally
				{
					client1.Close();
				}
			}
			finally
			{
				server.Close();
			}
		}