-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Tests): Add basic JobPool tests
- Loading branch information
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |