Skip to content

Commit

Permalink
improve test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkCiliaVincenti committed Nov 10, 2024
1 parent 0386195 commit 82bcc4e
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions AsyncKeyedLock.Tests/AsyncKeyedLocker/OriginalTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,22 @@ public async Task TestTimeoutOrNullBasic()
Assert.False(asyncKeyedLocker.IsInUse("test"));
}

[Fact]
public void TestTimeoutBasicWithOutParameter()
{
var asyncKeyedLocker = new AsyncKeyedLocker<string>(o => { o.PoolSize = 0; });
using (var myLock = asyncKeyedLocker.Lock("test", 0, out var entered))
{
Assert.True(entered);
Assert.True(asyncKeyedLocker.IsInUse("test"));
asyncKeyedLocker.Lock("test", 0, out entered);
Assert.False(entered);
asyncKeyedLocker.Lock("test", TimeSpan.Zero, out entered);
Assert.False(entered);
}
Assert.False(asyncKeyedLocker.IsInUse("test"));
}

[Fact]
public void TestTimeoutOrNullBasicWithOutParameter()
{
Expand All @@ -498,6 +514,10 @@ public void TestTimeoutOrNullBasicWithOutParameter()
{
Assert.NotNull(myLock);
Assert.True(asyncKeyedLocker.IsInUse("test"));
var entered = asyncKeyedLocker.LockOrNull("test", 0);
Assert.Null(entered);
entered = asyncKeyedLocker.LockOrNull("test", TimeSpan.Zero);
Assert.Null(entered);
}
Assert.False(asyncKeyedLocker.IsInUse("test"));
}
Expand Down

0 comments on commit 82bcc4e

Please sign in to comment.