-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for ServiceBusProcessorFactory
- Loading branch information
1 parent
03f0bee
commit 5b5fbfc
Showing
1 changed file
with
164 additions
and
0 deletions.
There are no files selected for viewing
164 changes: 164 additions & 0 deletions
164
test/Cabazure.Messaging.ServiceBus.Tests/Internal/ServiceBusProcessorFactoryTests.cs
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,164 @@ | ||
using Azure.Messaging.ServiceBus; | ||
using Cabazure.Messaging.ServiceBus.Internal; | ||
|
||
namespace Cabazure.Messaging.ServiceBus.Tests.Internal; | ||
|
||
public class ServiceBusProcessorFactoryTests | ||
{ | ||
[Theory, AutoNSubstituteData] | ||
public void Create_For_Topic_Gets_Client( | ||
[Frozen] IServiceBusClientProvider clientProvider, | ||
[Substitute] ServiceBusClient client, | ||
ServiceBusProcessorFactory sut, | ||
string connectionName, | ||
string topicName, | ||
string consumerGroupName, | ||
ServiceBusProcessorOptions options) | ||
{ | ||
clientProvider | ||
.GetClient(default) | ||
.ReturnsForAnyArgs(client); | ||
|
||
sut.Create( | ||
connectionName, | ||
topicName, | ||
consumerGroupName, | ||
options); | ||
|
||
clientProvider | ||
.Received(1) | ||
.GetClient(connectionName); | ||
} | ||
|
||
[Theory, AutoNSubstituteData] | ||
public void Create_For_Topic_Creates_Processor( | ||
[Frozen] IServiceBusClientProvider clientProvider, | ||
[Substitute] ServiceBusClient client, | ||
ServiceBusProcessorFactory sut, | ||
string connectionName, | ||
string topicName, | ||
string consumerGroupName, | ||
ServiceBusProcessorOptions options) | ||
{ | ||
clientProvider | ||
.GetClient(default) | ||
.ReturnsForAnyArgs(client); | ||
|
||
sut.Create( | ||
connectionName, | ||
topicName, | ||
consumerGroupName, | ||
options); | ||
|
||
client | ||
.Received(1) | ||
.CreateProcessor( | ||
topicName, | ||
consumerGroupName, | ||
options); | ||
} | ||
|
||
[Theory, AutoNSubstituteData] | ||
public void Create_For_Topic_Returns_Processor( | ||
[Frozen] IServiceBusClientProvider clientProvider, | ||
[Substitute] ServiceBusClient client, | ||
[Substitute] ServiceBusProcessor processor, | ||
ServiceBusProcessorFactory sut, | ||
string connectionName, | ||
string topicName, | ||
string consumerGroupName, | ||
ServiceBusProcessorOptions options) | ||
{ | ||
clientProvider | ||
.GetClient(default) | ||
.ReturnsForAnyArgs(client); | ||
client | ||
.CreateProcessor(default, default, default) | ||
.ReturnsForAnyArgs(processor); | ||
|
||
var result = sut.Create( | ||
connectionName, | ||
topicName, | ||
consumerGroupName, | ||
options); | ||
|
||
result | ||
.Should() | ||
.Be(processor); | ||
} | ||
|
||
[Theory, AutoNSubstituteData] | ||
public void Create_For_Queue_Gets_Client( | ||
[Frozen] IServiceBusClientProvider clientProvider, | ||
[Substitute] ServiceBusClient client, | ||
ServiceBusProcessorFactory sut, | ||
string connectionName, | ||
string queueName, | ||
ServiceBusProcessorOptions options) | ||
{ | ||
clientProvider | ||
.GetClient(default) | ||
.ReturnsForAnyArgs(client); | ||
|
||
sut.Create( | ||
connectionName, | ||
queueName, | ||
options); | ||
|
||
clientProvider | ||
.Received(1) | ||
.GetClient(connectionName); | ||
} | ||
|
||
[Theory, AutoNSubstituteData] | ||
public void Create_For_Queue_Creates_Processor( | ||
[Frozen] IServiceBusClientProvider clientProvider, | ||
[Substitute] ServiceBusClient client, | ||
ServiceBusProcessorFactory sut, | ||
string connectionName, | ||
string queueName, | ||
ServiceBusProcessorOptions options) | ||
{ | ||
clientProvider | ||
.GetClient(default) | ||
.ReturnsForAnyArgs(client); | ||
|
||
sut.Create( | ||
connectionName, | ||
queueName, | ||
options); | ||
|
||
client | ||
.Received(1) | ||
.CreateProcessor( | ||
queueName, | ||
options); | ||
} | ||
|
||
[Theory, AutoNSubstituteData] | ||
public void Create_For_Queue_Returns_Processor( | ||
[Frozen] IServiceBusClientProvider clientProvider, | ||
[Substitute] ServiceBusClient client, | ||
[Substitute] ServiceBusProcessor processor, | ||
ServiceBusProcessorFactory sut, | ||
string connectionName, | ||
string queueName, | ||
ServiceBusProcessorOptions options) | ||
{ | ||
clientProvider | ||
.GetClient(default) | ||
.ReturnsForAnyArgs(client); | ||
client | ||
.CreateProcessor(default, default(ServiceBusProcessorOptions)) | ||
.ReturnsForAnyArgs(processor); | ||
|
||
var result = sut.Create( | ||
connectionName, | ||
queueName, | ||
options); | ||
|
||
result | ||
.Should() | ||
.Be(processor); | ||
} | ||
} |