Skip to content

Commit

Permalink
InvokeAsync_FailedLockAcquisition_ThrowsTimeoutException
Browse files Browse the repository at this point in the history
  • Loading branch information
infofromca committed Oct 12, 2024
1 parent 4f665ce commit 4255865
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,28 @@ public async Task InvokeAsync_FailedSetup_ReturnsServiceUnavailable()
Assert.Equal(StatusCodes.Status503ServiceUnavailable, httpContext.Response.StatusCode);
}

[Fact]
public async Task InvokeAsync_FailedLockAcquisition_ThrowsTimeoutException()
{
// Arrange
_shellSettings.State = TenantState.Uninitialized;

SetupDistributedLockMock(false);

var httpContext = new DefaultHttpContext();

var middleware = new AutoSetupMiddleware(
next: (innerHttpContext) => Task.CompletedTask,
_mockShellHost.Object,
_shellSettings,
_mockShellSettingsManager.Object,
_mockDistributedLock.Object,
_mockOptions.Object);

// Act & Assert
await Assert.ThrowsAsync<TimeoutException>(() => middleware.InvokeAsync(httpContext));
}

private void SetupDistributedLockMock(bool acquireLock)
{
var mockLocker = new Mock<ILocker>();
Expand Down

0 comments on commit 4255865

Please sign in to comment.