Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix mocking of session processor #39650

Merged
merged 2 commits into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ protected ServiceBusProcessor()
{
// assign default options since some of the properties reach into the options
Options = new ServiceBusProcessorOptions();
_sessionIds = Array.Empty<string>();
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,22 @@ public async Task CannotStartProcessorWhenConnectionIsClosed()
await processor.DisposeAsync();
}

[Test]
public void CanUpdateConcurrencyOnMockProcessor()
{
var mockProcessor = new Mock<ServiceBusProcessor> { CallBase = true };
mockProcessor.Object.UpdateConcurrency(5);
Assert.AreEqual(5, mockProcessor.Object.MaxConcurrentCalls);
}

[Test]
public void CanUpdatePrefetchOnMockProcessor()
{
var mockProcessor = new Mock<ServiceBusProcessor>() { CallBase = true };
mockProcessor.Object.UpdatePrefetchCount(10);
Assert.AreEqual(10, mockProcessor.Object.PrefetchCount);
}

[Test]
public async Task CloseRespectsCancellationToken()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,23 @@ public async Task CanRaiseLockLostOnMockProcessor()
Assert.IsTrue(sessionCloseCalled);
}

[Test]
public void CanUpdateConcurrencyOnMockSessionProcessor()
{
var mockProcessor = new MockSessionProcessor();
mockProcessor.UpdateConcurrency(5, 2);
Assert.AreEqual(5, mockProcessor.MaxConcurrentSessions);
Assert.AreEqual(2, mockProcessor.MaxConcurrentCallsPerSession);
}

[Test]
public void CanUpdatePrefetchOnMockSessionProcessor()
{
var mockProcessor = new MockSessionProcessor();
mockProcessor.UpdatePrefetchCount(10);
Assert.AreEqual(10, mockProcessor.PrefetchCount);
}

[Test]
public async Task CloseRespectsCancellationToken()
{
Expand Down