forked from msoelr2500/Disruptor-net
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTimeoutBlockingWaitStrategyTest.cs
39 lines (32 loc) · 1.06 KB
/
TimeoutBlockingWaitStrategyTest.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using System;
using Moq;
using NUnit.Framework;
namespace Disruptor.Tests
{
[TestFixture]
public class TimeoutBlockingWaitStrategyTest
{
[Test]
public void ShouldTimeoutWaitFor()
{
var sequenceBarrier = new Mock<ISequenceBarrier>();
var theTimeout = TimeSpan.FromMilliseconds(500);
TimeoutBlockingWaitStrategy waitStrategy = new TimeoutBlockingWaitStrategy(theTimeout);
Sequence cursor = new Sequence(5);
Sequence dependent = cursor;
var t0 = DateTime.UtcNow;
try
{
waitStrategy.WaitFor(6, cursor, dependent, sequenceBarrier.Object);
throw new ApplicationException("TimeoutException should have been thrown");
}
catch (TimeoutException e)
{
}
var t1 = DateTime.UtcNow;
var timeWaiting = t1 - t0;
sequenceBarrier.Verify(x => x.CheckAlert());
Assert.That(timeWaiting, Is.GreaterThanOrEqualTo(theTimeout));
}
}
}