Skip to content

Commit

Permalink
feat(Tests): Add basic JobPool tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mycroes committed Feb 28, 2024
1 parent d58463d commit 4b335b0
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions Sally7.Tests/RequestExecutor/JobPoolTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using System.Threading.Channels;
using Sally7.RequestExecutor;

namespace Sally7.Tests.RequestExecutor;

public class JobPoolTests
{
[Fact]
public async Task RentJobIdAsync_Throws_If_Disposed_And_Depleted()
{
// Arrange
var sut = new JobPool(1);
sut.Dispose();
_ = await sut.RentJobIdAsync(CancellationToken.None); // Empty the pool

// Act
// Assert
await Should.ThrowAsync<ChannelClosedException>(() => sut.RentJobIdAsync(CancellationToken.None).AsTask());
}

[Fact]
public void ReturnJobId_Does_Not_Throw_If_Disposed()
{
// Arrange
var sut = new JobPool(1);
var jobId = sut.RentJobIdAsync(CancellationToken.None).Result;
sut.Dispose();

// Act
// Assert
sut.ReturnJobId(jobId);
}
}

0 comments on commit 4b335b0

Please sign in to comment.