public void Publish_long_running_should_not_throw_exception() { DummyJobWithArgs.Publish(new DummyJobArgs { SomeId = 1 }, 10_000); // 10 sec timeout using (var tokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(10))) { while (_performCount < 1) { Task.Delay(100, tokenSource.Token).Wait(); } } Assert.AreEqual(1, _performCount); }
public void Publish_should_not_throw_exception() { // warm up (establish connection) DummyJobWithArgs2.Publish(new DummyJobArgs2()); using (var tokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(10))) { while (_performCount < 2) { Task.Delay(100, tokenSource.Token).Wait(tokenSource.Token); } } var watch = Stopwatch.StartNew(); JobBatch.Do(() => { for (var i = 0; i < 100_000; i++) { DummyJobWithArgs.Publish(new DummyJobArgs { SomeId = i }); } }); watch.Stop(); Console.WriteLine($"Elapsed: {watch.Elapsed}"); using (var tokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(10))) { while (_performCount < 100_002) { Task.Delay(100, tokenSource.Token).Wait(tokenSource.Token); } } Assert.AreEqual(100_002, _performCount); }
public void Publish_should_not_throw_exception() { JobBatch.Do(() => { for (var i = 0; i < 100_000; i++) { DummyJobWithArgs.Publish(new DummyJobArgs { SomeId = i }); } }); DummyJobWithArgs2.Publish(new DummyJobArgs2()); using (var tokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(10))) { while (_performCount < 100_002) { Task.Delay(100, tokenSource.Token).Wait(); } } Assert.AreEqual(100_002, _performCount); }