public void OnException_Should_Get_Passed_To_Subscribers()
        {
            CountdownEvent weAreDone = new CountdownEvent(1);

            {
                int freePort = TcpPortFree();
                var pubSub   = new SubjectNetMQ <int>("tcp://127.0.0.1:" + freePort);
                pubSub.Subscribe(
                    o =>
                {
                    // If this gets called more than max times, it will throw an exception as it is going through 0.
                    Assert.Fail();
                },
                    ex =>
                {
                    Console.Write("Exception: {0}", ex.Message);
                    Assert.True(ex.Message.Contains("passed"));
                    weAreDone.Signal();
                },
                    () =>
                {
                    Assert.Fail();
                });

                pubSub.OnError(new Exception("passed"));
            }
            if (weAreDone.Wait(TimeSpan.FromSeconds(10)) == false)             // Blocks until _countdown.Signal has been called.
            {
                Assert.Fail("Timed out, this test should complete in 10 seconds.");
            }
        }
Exemplo n.º 2
0
        public void OnException_Should_Get_Passed_To_Subscribers()
        {
            NUnitUtils.PrintTestName();

            var sw = Stopwatch.StartNew();

            var weAreDone = new CountdownEvent(1);

            {
                var freePort = NUnitUtils.TcpPortFree();
                var pubSub   = new SubjectNetMQ <int>("tcp://127.0.0.1:" + freePort, loggerDelegate: Console.Write);
                pubSub.Subscribe(
                    o =>
                {
                    // If this gets called more than max times, it will throw an exception as it is going through 0.
                    Assert.Fail();
                },
                    ex =>
                {
                    Console.Write("Exception: {0}", ex.Message);
                    Assert.True(ex.Message.Contains("passed"));
                    weAreDone.Signal();
                },
                    () => { Assert.Fail(); });

                pubSub.OnError(new Exception("passed"));
            }

            if (weAreDone.Wait(GlobalTimeout.Timeout) == false) // Blocks until _countdown.Signal has been called.
            {
                Assert.Fail("Timed out, this test should complete in {0} seconds.", GlobalTimeout.Timeout.TotalSeconds);
            }

            NUnitUtils.PrintElapsedTime(sw.Elapsed);
        }
		public void OnException_Should_Get_Passed_To_Subscribers()
		{
			CountdownEvent weAreDone = new CountdownEvent(1);
			{
				int freePort = TcpPortFree();
				var pubSub = new SubjectNetMQ<int>("tcp://127.0.0.1:" + freePort);
				pubSub.Subscribe(
					o =>
					{
						// If this gets called more than max times, it will throw an exception as it is going through 0.
						Assert.Fail();
					},
					ex =>
					{
						Console.Write("Exception: {0}", ex.Message);
						Assert.True(ex.Message.Contains("passed"));
						weAreDone.Signal();
					},
					() =>
					{
						Assert.Fail();
					});

				pubSub.OnError(new Exception("passed"));
			}
			if (weAreDone.Wait(TimeSpan.FromSeconds(10)) == false) // Blocks until _countdown.Signal has been called.
			{
				Assert.Fail("Timed out, this test should complete in 10 seconds.");
			}
		}
        public void OnException_Should_Get_Passed_To_Subscribers()
        {
            NUnitUtils.PrintTestName();

            var sw = Stopwatch.StartNew();

            var weAreDone = new CountdownEvent(1);
            var passed = false;
            {
                var freePort = NUnitUtils.TcpPortFree();
                var pubSub = new SubjectNetMQ<int>("tcp://127.0.0.1:" + freePort, loggerDelegate: Console.Write);
                pubSub.Subscribe(
                    o =>
                    {
                        // If this gets called more than max times, it will throw an exception as it is going through 0.
                        Assert.Fail();
                    },
                    ex =>
                    {
                        Console.Write("Exception: {0}", ex.Message);
                        if (ex.Message.Contains("passed") == true)
                        {
                            passed = true;
                        }
                        weAreDone.Signal();
                    },
                    () => { Assert.Fail(); });

                pubSub.OnError(new Exception("passed"));
            }

            if (weAreDone.Wait(GlobalTimeout.Timeout) == false || passed == false) // Blocks until _countdown.Signal has been called.
            {
                Assert.Fail("Timed out, this test should complete in {0} seconds.", GlobalTimeout.Timeout.TotalSeconds);
            }

            if (passed == false) // Blocks until _countdown.Signal has been called.
            {
                Assert.Fail("Expected exception text did not arrive back.");
            }

            NUnitUtils.PrintElapsedTime(sw.Elapsed);
        }