예제 #1
0
        public void Roundtrip()
        {
            Console.WriteLine("Starting...");
            var client = new MemoryClient();
            var passed = false;
            var pager = new PagedClient(client, "test");

            using (var s = new CancellationTokenSource(TimeSpan.FromSeconds(10))) {

                var unpackedMessage = new UnpackedMessage(GetBytes(Constants.MaxKeySize),
                    GetBytes(Constants.MaxValueSize * 5 + 1));
                Console.WriteLine("Pub...");
                pager.Publish(new[] {

                    unpackedMessage

                }, s.Token);
                Console.WriteLine("Waiting...");

                pager.ChaseEventsForever(s.Token, (id, subscription) => {
                    CollectionAssert.AreEqual(unpackedMessage.Value, id.Value);
                    CollectionAssert.AreEqual(unpackedMessage.Key, id.Key);
                    passed = true;
                    Console.WriteLine("Got it" + id);
                    s.Cancel();

                });
            }

            if (!passed) {
                Assert.Fail("Failed");
            }
        }
예제 #2
0
		public void Posting() {
			using (var client = new MemoryClient()) {
				var task = client.PostMessagesAsync("test", new[] {Message.Create("Key", new byte[0]),});
				var ok = task.Wait(1000);

				Assert.IsTrue(ok);
				Assert.AreEqual(25, task.Result.Position);
			}
		}
예제 #3
0
		public void Publisher() {
			using (var client = new MemoryClient())
			{
				Publish(client, Message.Create("Key", new byte[0]));
			}
		}