diff --git a/Sally7.Tests/RequestExecutor/JobPoolTests.cs b/Sally7.Tests/RequestExecutor/JobPoolTests.cs new file mode 100644 index 0000000..0d6e1ff --- /dev/null +++ b/Sally7.Tests/RequestExecutor/JobPoolTests.cs @@ -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(() => 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); + } +} \ No newline at end of file