public void OnCompleted_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. Console.Write("FAIL!"); Assert.Fail(); }, ex => { Console.Write("FAIL!"); Assert.Fail(); }, () => { Console.Write("Pass!"); weAreDone.Signal(); }); pubSub.OnCompleted(); } 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 OnCompleted_Should_Get_Passed_To_Subscribers() { NUnitUtils.PrintTestName(); var sw = Stopwatch.StartNew(); List <TimeSpan> timeMilliseconds = new List <TimeSpan>(); var weAreDone = new CountdownEvent(1); { timeMilliseconds.Add(sw.Elapsed); var freePort = NUnitUtils.TcpPortFree(); timeMilliseconds.Add(sw.Elapsed); var pubSub = new SubjectNetMQ <int>("tcp://127.0.0.1:" + freePort, loggerDelegate: Console.Write); timeMilliseconds.Add(sw.Elapsed); pubSub.Subscribe( o => { // If this gets called more than max times, it will throw an exception as it is going through 0. //Console.Write("FAIL!"); //Assert.Fail(); }, ex => { Console.Write("FAIL!"); Assert.Fail(); }, () => { Console.Write("Pass!"); weAreDone.Signal(); }); timeMilliseconds.Add(sw.Elapsed); pubSub.OnCompleted(); timeMilliseconds.Add(sw.Elapsed); } for (int i = 0; i < timeMilliseconds.Count; i++) { var t = timeMilliseconds[i]; Console.WriteLine("- Stage {0}: {1:0,000} milliseconds", i, t.TotalMilliseconds); } 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 OnCompleted_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. Console.Write("FAIL!"); Assert.Fail(); }, ex => { Console.Write("FAIL!"); Assert.Fail(); }, () => { Console.Write("Pass!"); weAreDone.Signal(); }); pubSub.OnCompleted(); } 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 OnCompleted_Should_Get_Passed_To_Subscribers() { NUnitUtils.PrintTestName(); var sw = Stopwatch.StartNew(); List<TimeSpan> timeMilliseconds = new List<TimeSpan>(); var weAreDone = new CountdownEvent(1); { timeMilliseconds.Add(sw.Elapsed); var freePort = NUnitUtils.TcpPortFree(); timeMilliseconds.Add(sw.Elapsed); var pubSub = new SubjectNetMQ<int>("tcp://127.0.0.1:" + freePort, loggerDelegate: Console.Write); timeMilliseconds.Add(sw.Elapsed); pubSub.Subscribe( o => { // If this gets called more than max times, it will throw an exception as it is going through 0. //Console.Write("FAIL!"); //Assert.Fail(); }, ex => { Console.Write("FAIL!"); Assert.Fail(); }, () => { Console.Write("Pass!"); weAreDone.Signal(); }); timeMilliseconds.Add(sw.Elapsed); pubSub.OnCompleted(); timeMilliseconds.Add(sw.Elapsed); } for (int i = 0; i < timeMilliseconds.Count; i++) { var t = timeMilliseconds[i]; Console.WriteLine("- Stage {0}: {1:0,000} milliseconds", i, t.TotalMilliseconds); } 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); }