Skip to content

Commit

Permalink
Update LockEntryFacts.cs
Browse files Browse the repository at this point in the history
Remove the test, because it's already tested in the upper level, and needs to be checked at the dispatcher level.
  • Loading branch information
odinserj committed Jun 16, 2024
1 parent 00be2b7 commit 143891f
Showing 1 changed file with 0 additions and 39 deletions.
39 changes: 0 additions & 39 deletions tests/Hangfire.InMemory.Tests/Entities/LockEntryFacts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,45 +74,6 @@ public void TryAcquire_DoesNotAcquire_AlreadyOwnedLock()
Assert.False(cleanUp);
}

[Fact]
public void TryAcquire_CanAcquire_AnAlreadyReleasedLock_ByAnotherOwner()
{
var entry = CreateLock();
var completed = new ManualResetEventSlim(initialState: false);
var another = new object();
var cleanUp = false;
Exception exception = null;

entry.TryAcquire(another, TimeSpan.Zero, out _, out _);

ThreadPool.QueueUserWorkItem(delegate
{
try
{
var acquired = entry.TryAcquire(_owner, TimeSpan.FromSeconds(5), out _, out _);
entry.Release(_owner, out cleanUp);

Assert.True(acquired, "Should be acquired");
}
catch (Exception ex)
{
exception = ex;
}
finally
{
completed.Set();
}
});

Thread.Sleep(100); // Ensure second TryAcquire call is made
entry.Release(another, out var anotherCleanUp);

completed.Wait();

if (exception != null) Assert.False(true, exception.ToString());
Assert.True((cleanUp || anotherCleanUp) && (cleanUp != anotherCleanUp), "Should be clean up strictly once");
}

[Fact]
public void TryAcquire_OnAFinalizedLock_RequiresRetry()
{
Expand Down

0 comments on commit 143891f

Please sign in to comment.