示例#1
0
		public static void SendAndReceiveSingleMessage(IMessageChannel channel)
		{
			channel.Open();
			channel.Clear();

			var m = GetNewMessage();

			channel.Send(m);

			var m2 = channel.ReceiveSingle(TimeSpan.MaxValue);

			Assert.NotNull(m2);

			Assert.AreEqual(m.Identifier, m2.Identifier);

			channel.Close();
		}
示例#2
0
		public static void Clear(IMessageChannel channel)
		{
			channel.Open();

			for (var i = 0; i < 5; i++)
			{
				var m = new FakeMessage();
				channel.Send(m);
			}

			channel.Clear();

			var messages = channel.ReceiveMany(5, TimeSpan.MaxValue);

			Assert.AreEqual(0, messages.Count());

			channel.Close();
		}
示例#3
0
		public static void ReceiveTimeout(IMessageChannel channel)
		{
			var ts = new TimeSpan(0, 0, 0, 0, 500);

			channel.Open();
			channel.Clear();

			var m = new FakeMessage();
			var m2 = new FakeMessage();

			channel.Send(m);
			channel.Send(m2);

			var count = 0;
			foreach (var msg in channel.ReceiveMany(2, ts))
			{
				count++;
				Thread.Sleep(500);
			}

			Assert.AreEqual(1, count);
		}
示例#4
0
		public static void StateTransitions(IMessageChannel channel)
		{
			Assert.AreNotEqual(ChannelState.Closed, channel.State);

			var newState = channel.Open();
			channel.Clear();

			Assert.AreEqual(ChannelState.Open, newState);

			newState = channel.Close();

			Assert.AreEqual(ChannelState.Closed, newState);
		}