public void ShouldTimeoutWaitFor()
        {
            var sequenceBarrier = new DummySequenceBarrier();

            var      theTimeout   = TimeSpan.FromMilliseconds(500);
            var      waitStrategy = new LiteTimeoutBlockingWaitStrategy(theTimeout);
            Sequence cursor       = new Sequence(5);
            Sequence dependent    = cursor;

            var t0 = DateTime.UtcNow;

            try
            {
                waitStrategy.WaitFor(6, cursor, dependent, sequenceBarrier);
                Assert.Fail("TimeoutException should have been thrown");
            }
            catch (TimeoutException)
            {
            }

            var t1 = DateTime.UtcNow;

            var timeWaiting = t1 - t0;

            Assert.That(timeWaiting, Is.GreaterThanOrEqualTo(theTimeout));
        }
        public void ShouldTimeoutWaitFor()
        {
            var sequenceBarrier = new Mock<ISequenceBarrier>();

            var theTimeout = TimeSpan.FromMilliseconds(500);
            var waitStrategy = new LiteTimeoutBlockingWaitStrategy(theTimeout);
            Sequence cursor = new Sequence(5);
            Sequence dependent = cursor;

            var t0 = DateTime.UtcNow;

            try
            {
                waitStrategy.WaitFor(6, cursor, dependent, sequenceBarrier.Object);
                Assert.Fail("TimeoutException should have been thrown");
            }
            catch (TimeoutException)
            {
            }

            var t1 = DateTime.UtcNow;

            var timeWaiting = t1 - t0;

            Assert.That(timeWaiting, Is.GreaterThanOrEqualTo(theTimeout));
        }
        public void ShouldTimeoutWaitFor()
        {
            var sequenceBarrier = new DummySequenceBarrier();

            var theTimeout   = TimeSpan.FromMilliseconds(500);
            var waitStrategy = new LiteTimeoutBlockingWaitStrategy(theTimeout);
            var cursor       = new Sequence(5);
            var dependent    = cursor;

            var stopwatch = Stopwatch.StartNew();

            Assert.Throws <TimeoutException>(() => waitStrategy.WaitFor(6, cursor, dependent, sequenceBarrier));

            stopwatch.Stop();

            // Required to make the test pass on azure pipelines.
            var tolerance = TimeSpan.FromMilliseconds(25);

            Assert.That(stopwatch.Elapsed, Is.GreaterThanOrEqualTo(theTimeout - tolerance));
        }