From c8660d737a0ce53c254853e07015745baa372a6e Mon Sep 17 00:00:00 2001 From: Mark Cilia Vincenti Date: Fri, 29 Dec 2023 17:29:51 +0100 Subject: [PATCH] Coverage fix --- .../AsyncKeyedLocker/OriginalTests.cs | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/AsyncKeyedLock.Tests/AsyncKeyedLocker/OriginalTests.cs b/AsyncKeyedLock.Tests/AsyncKeyedLocker/OriginalTests.cs index 0a57ac3..4617718 100644 --- a/AsyncKeyedLock.Tests/AsyncKeyedLocker/OriginalTests.cs +++ b/AsyncKeyedLock.Tests/AsyncKeyedLocker/OriginalTests.cs @@ -1,10 +1,7 @@ using AsyncKeyedLock.Tests.Helpers; using FluentAssertions; -using FluentAssertions.Common; using ListShuffle; -using System.Collections; using System.Collections.Concurrent; -using System.Collections.Generic; using Xunit; namespace AsyncKeyedLock.Tests.AsyncKeyedLocker @@ -139,6 +136,23 @@ public void TestDisposeDoesNotThrow() action.Should().NotThrow(); } + [Fact] + public void TestDisposeDoesNotThrowDespiteDisposedSemaphoreSlim() + { + Action action = () => + { + var asyncKeyedLocker = new AsyncKeyedLocker(o => + { + o.PoolSize = 20; + o.PoolInitialFill = 1; + }); + AsyncKeyedLockReleaser releaser = (AsyncKeyedLockReleaser)asyncKeyedLocker.Lock("test"); + releaser.SemaphoreSlim.Dispose(); + asyncKeyedLocker.Dispose(); + }; + action.Should().NotThrow(); + } + [Fact] public void TestIndexDoesNotThrow() {