Skip to content

Commit

Permalink
Cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkCiliaVincenti committed Nov 10, 2024
1 parent adf4999 commit 7cabe72
Showing 1 changed file with 25 additions and 43 deletions.
68 changes: 25 additions & 43 deletions AsyncKeyedLock.Tests/AsyncNonKeyedLockerTests/OriginalTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -229,15 +229,13 @@ public void TestMaxCount()
using var asyncNonKeyedLocker = new AsyncNonKeyedLocker(2);
Assert.Equal(0, asyncNonKeyedLocker.GetRemainingCount());
Assert.Equal(asyncNonKeyedLocker.MaxCount, asyncNonKeyedLocker.GetCurrentCount());
using (var myLock = (AsyncNonKeyedLockReleaser)asyncNonKeyedLocker.Lock())
using (var myLock = asyncNonKeyedLocker.Lock())
{
Assert.Equal(1, asyncNonKeyedLocker.GetRemainingCount());
Assert.Equal(1, asyncNonKeyedLocker.GetCurrentCount());
using (var myLock2 = (AsyncNonKeyedLockReleaser)asyncNonKeyedLocker.Lock())
{
Assert.Equal(asyncNonKeyedLocker.MaxCount, asyncNonKeyedLocker.GetRemainingCount());
Assert.Equal(0, asyncNonKeyedLocker.GetCurrentCount());
}
using var myLock2 = asyncNonKeyedLocker.Lock();
Assert.Equal(asyncNonKeyedLocker.MaxCount, asyncNonKeyedLocker.GetRemainingCount());
Assert.Equal(0, asyncNonKeyedLocker.GetCurrentCount());
}
Assert.Equal(0, asyncNonKeyedLocker.GetRemainingCount());
Assert.Equal(asyncNonKeyedLocker.MaxCount, asyncNonKeyedLocker.GetCurrentCount());
Expand Down Expand Up @@ -296,11 +294,9 @@ public void TestLockAndMillisecondsTimeout()
Assert.True(entered);
Assert.Equal(1, asyncNonKeyedLocker.GetRemainingCount());
Assert.Equal(0, asyncNonKeyedLocker.GetCurrentCount());
using (var myLock2 = asyncNonKeyedLocker.Lock(0, out entered))
{
Assert.False(entered);
Assert.False(((AsyncNonKeyedLockTimeoutReleaser)myLock2).EnteredSemaphore);
}
using var myLock2 = asyncNonKeyedLocker.Lock(0, out entered);
Assert.False(entered);
Assert.False(((AsyncNonKeyedLockTimeoutReleaser)myLock2).EnteredSemaphore);
}
Assert.Equal(0, asyncNonKeyedLocker.GetRemainingCount());
Assert.Equal(1, asyncNonKeyedLocker.GetCurrentCount());
Expand All @@ -317,10 +313,8 @@ public void TestLockOrNullAndMillisecondsTimeout()
Assert.NotNull(myLock);
Assert.Equal(1, asyncNonKeyedLocker.GetRemainingCount());
Assert.Equal(0, asyncNonKeyedLocker.GetCurrentCount());
using (var myLock2 = asyncNonKeyedLocker.LockOrNull(0))
{
Assert.Null(myLock2);
}
using var myLock2 = asyncNonKeyedLocker.LockOrNull(0);
Assert.Null(myLock2);
}
Assert.Equal(0, asyncNonKeyedLocker.GetRemainingCount());
Assert.Equal(1, asyncNonKeyedLocker.GetCurrentCount());
Expand All @@ -337,11 +331,9 @@ public void TestLockAndTimeout()
Assert.True(entered);
Assert.Equal(1, asyncNonKeyedLocker.GetRemainingCount());
Assert.Equal(0, asyncNonKeyedLocker.GetCurrentCount());
using (var myLock2 = asyncNonKeyedLocker.Lock(TimeSpan.Zero, out entered))
{
Assert.False(entered);
Assert.False(((AsyncNonKeyedLockTimeoutReleaser)myLock2).EnteredSemaphore);
}
using var myLock2 = asyncNonKeyedLocker.Lock(TimeSpan.Zero, out entered);
Assert.False(entered);
Assert.False(((AsyncNonKeyedLockTimeoutReleaser)myLock2).EnteredSemaphore);
}
Assert.Equal(0, asyncNonKeyedLocker.GetRemainingCount());
Assert.Equal(1, asyncNonKeyedLocker.GetCurrentCount());
Expand All @@ -358,10 +350,8 @@ public void TestLockOrNullAndTimeout()
Assert.NotNull(myLock);
Assert.Equal(1, asyncNonKeyedLocker.GetRemainingCount());
Assert.Equal(0, asyncNonKeyedLocker.GetCurrentCount());
using (var myLock2 = asyncNonKeyedLocker.LockOrNull(TimeSpan.Zero))
{
Assert.Null(myLock2);
}
using var myLock2 = asyncNonKeyedLocker.LockOrNull(TimeSpan.Zero);
Assert.Null(myLock2);
}
Assert.Equal(0, asyncNonKeyedLocker.GetRemainingCount());
Assert.Equal(1, asyncNonKeyedLocker.GetCurrentCount());
Expand All @@ -384,11 +374,9 @@ public void TestLockAndMillisecondsTimeoutAndCancellationToken()
Assert.True(entered);
Assert.Equal(1, asyncNonKeyedLocker.GetRemainingCount());
Assert.Equal(0, asyncNonKeyedLocker.GetCurrentCount());
using (var myLock2 = asyncNonKeyedLocker.Lock(0, CancellationToken.None, out entered))
{
Assert.False(entered);
Assert.False(((AsyncNonKeyedLockTimeoutReleaser)myLock2).EnteredSemaphore);
}
using var myLock2 = asyncNonKeyedLocker.Lock(0, CancellationToken.None, out entered);
Assert.False(entered);
Assert.False(((AsyncNonKeyedLockTimeoutReleaser)myLock2).EnteredSemaphore);
}
Assert.Equal(0, asyncNonKeyedLocker.GetRemainingCount());
Assert.Equal(1, asyncNonKeyedLocker.GetCurrentCount());
Expand All @@ -411,10 +399,8 @@ public void TestLockOrNullAndMillisecondsTimeoutAndCancellationToken()
Assert.NotNull(myLock);
Assert.Equal(1, asyncNonKeyedLocker.GetRemainingCount());
Assert.Equal(0, asyncNonKeyedLocker.GetCurrentCount());
using (var myLock2 = asyncNonKeyedLocker.LockOrNull(0, CancellationToken.None))
{
Assert.Null(myLock2);
}
using var myLock2 = asyncNonKeyedLocker.LockOrNull(0, CancellationToken.None);
Assert.Null(myLock2);
}
Assert.Equal(0, asyncNonKeyedLocker.GetRemainingCount());
Assert.Equal(1, asyncNonKeyedLocker.GetCurrentCount());
Expand Down Expand Up @@ -493,11 +479,9 @@ public void TestLockAndTimeoutAndCancellationToken()
Assert.True(entered);
Assert.Equal(1, asyncNonKeyedLocker.GetRemainingCount());
Assert.Equal(0, asyncNonKeyedLocker.GetCurrentCount());
using (var myLock2 = asyncNonKeyedLocker.Lock(TimeSpan.Zero, CancellationToken.None, out entered))
{
Assert.False(entered);
Assert.False(((AsyncNonKeyedLockTimeoutReleaser)myLock2).EnteredSemaphore);
}
using var myLock2 = asyncNonKeyedLocker.Lock(TimeSpan.Zero, CancellationToken.None, out entered);
Assert.False(entered);
Assert.False(((AsyncNonKeyedLockTimeoutReleaser)myLock2).EnteredSemaphore);
}
Assert.Equal(0, asyncNonKeyedLocker.GetRemainingCount());
Assert.Equal(1, asyncNonKeyedLocker.GetCurrentCount());
Expand All @@ -520,10 +504,8 @@ public void TestLockOrNullAndTimeoutAndCancellationToken()
Assert.NotNull(myLock);
Assert.Equal(1, asyncNonKeyedLocker.GetRemainingCount());
Assert.Equal(0, asyncNonKeyedLocker.GetCurrentCount());
using (var myLock2 = asyncNonKeyedLocker.LockOrNull(TimeSpan.Zero, CancellationToken.None))
{
Assert.Null(myLock2);
}
using var myLock2 = asyncNonKeyedLocker.LockOrNull(TimeSpan.Zero, CancellationToken.None);
Assert.Null(myLock2);
}
Assert.Equal(0, asyncNonKeyedLocker.GetRemainingCount());
Assert.Equal(1, asyncNonKeyedLocker.GetCurrentCount());
Expand Down Expand Up @@ -585,4 +567,4 @@ public void TestLockOrNullAndInfiniteTimeoutAndCancelledCancellationToken()
entered.Should().BeFalse();
}
}
}
}

0 comments on commit 7cabe72

Please sign in to comment.