Skip to content

Commit

Permalink
Fix TestBlockingConcurrentLocks test not correctly handling assertion…
Browse files Browse the repository at this point in the history
…s on other threads
  • Loading branch information
samcook committed Apr 27, 2015
1 parent af0cf23 commit 943f6b7
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion RedLock.Tests/RedisLockTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ public void TestOverlappingLocks()
[Test]
public void TestBlockingConcurrentLocks()
{
var locksAcquired = 0;

using (var redisLockFactory = new RedisLockFactory(AllActiveEndPoints, logger))
{
var resource = String.Format("testblockingconcurrentlocks-{0}", Guid.NewGuid());
Expand All @@ -113,7 +115,10 @@ public void TestBlockingConcurrentLocks()
TimeSpan.FromSeconds(0.5)))
{
logger.InfoWrite("Entering lock");
Assert.That(redisLock.IsAcquired, Is.True);
if (redisLock.IsAcquired)
{
Interlocked.Increment(ref locksAcquired);
}
Thread.Sleep(4000);
logger.InfoWrite("Leaving lock");
}
Expand All @@ -129,6 +134,8 @@ public void TestBlockingConcurrentLocks()
thread.Join();
}
}

Assert.That(locksAcquired, Is.EqualTo(2));
}

[Test]
Expand Down

0 comments on commit 943f6b7

Please sign in to comment.