Skip to content

Commit

Permalink
More coverage tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkCiliaVincenti committed Dec 29, 2023
1 parent 4b1fffa commit efdeced
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions AsyncKeyedLock.Tests/AsyncKeyedLocker/OriginalTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,67 @@ public void TestDisposeDoesNotThrow()
o.PoolSize = 20;
o.PoolInitialFill = 1;
});
asyncKeyedLocker.Lock("test");
asyncKeyedLocker.Dispose();
};
action.Should().NotThrow();
}

[Fact]
public void TestIndexDoesNotThrow()
{
var asyncKeyedLocker = new AsyncKeyedLocker<string>();
asyncKeyedLocker.Lock("test");
asyncKeyedLocker.Index.Count.Should().Be(1);
asyncKeyedLocker.Dispose();
}

[Fact]
public void TestReadingMaxCount()
{
var asyncKeyedLocker = new AsyncKeyedLocker<string>(o => o.MaxCount = 2);
asyncKeyedLocker.MaxCount.Should().Be(2);
}

[Fact]
public void TestReadingMaxCountViaParameter()
{
var asyncKeyedLocker = new AsyncKeyedLocker<string>(new AsyncKeyedLockOptions(2));
asyncKeyedLocker.MaxCount.Should().Be(2);
}

[Fact]
public void TestReadingMaxCountViaParameterWithComparer()
{
var asyncKeyedLocker = new AsyncKeyedLocker<string>(new AsyncKeyedLockOptions(2), EqualityComparer<string>.Default);
asyncKeyedLocker.MaxCount.Should().Be(2);
}

[Fact]
public void TestReadingMaxCountViaParameterWithConcurrencyLevelAndCapacity()
{
var asyncKeyedLocker = new AsyncKeyedLocker<string>(new AsyncKeyedLockOptions(2), Environment.ProcessorCount, 100);
asyncKeyedLocker.MaxCount.Should().Be(2);
}

[Fact]
public void TestReadingMaxCountViaParameterWithConcurrencyLevelAndCapacityAndComparer()
{
var asyncKeyedLocker = new AsyncKeyedLocker<string>(new AsyncKeyedLockOptions(2), Environment.ProcessorCount, 100, EqualityComparer<string>.Default);
asyncKeyedLocker.MaxCount.Should().Be(2);
}

[Fact]
public void TestGetCurrentCount()
{
var asyncKeyedLocker = new AsyncKeyedLocker<string>();
asyncKeyedLocker.GetRemainingCount("test").Should().Be(0);
asyncKeyedLocker.GetCurrentCount("test").Should().Be(1);
asyncKeyedLocker.Lock("test");
asyncKeyedLocker.GetRemainingCount("test").Should().Be(1);
asyncKeyedLocker.GetCurrentCount("test").Should().Be(0);
}

[Fact]
public async Task TestTimeoutBasic()
{
Expand Down

0 comments on commit efdeced

Please sign in to comment.