Repository navigation
feat(ServiceBus): Add method to get HTTP connection string #1622
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
Merged
HofmeisterAn
merged 10 commits into
testcontainers:develop
from
NelsonBN:feature/add-method-get-http-connection-string
Jan 17, 2026
Merged
Changes from 1 commit
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
22e9217
feat(ServiceBusContainer): add method to get HTTP connection string
NelsonBN c1b7240
chore: refactor small issues
NelsonBN 13fbc96
chore: removed blank lines
NelsonBN ad43e2e
chore: removed blank lines
NelsonBN 0bdfe63
docs: update comments
NelsonBN 8bea3b8
refactor: Removed unnecessary keyword from namespace
NelsonBN e5730b6
chore: Move using to global usings file
HofmeisterAn fcd08ce
Merge remote-tracking branch 'origin/develop' into fork/NelsonBN/feat…
HofmeisterAn ae699a2
chore: Assert null receivedMessage
HofmeisterAn 39e4ecd
Merge remote-tracking branch 'origin/develop' into fork/NelsonBN/feat…
HofmeisterAn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
79 changes: 79 additions & 0 deletions
79
tests/Testcontainers.ServiceBus.Tests/ServiceBusAdministrationClientTest.cs
This file contains hidden or 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,79 @@ | ||
| using Azure.Messaging.ServiceBus.Administration; | ||
|
|
||
| namespace Testcontainers.ServiceBus.Tests; | ||
|
NelsonBN marked this conversation as resolved.
Resolved
|
||
|
|
||
| public abstract class ServiceBusAdministrationClientTest : IAsyncLifetime | ||
| { | ||
| private readonly ServiceBusContainer _serviceBusContainer; | ||
|
|
||
| private ServiceBusAdministrationClientTest(ServiceBusContainer serviceBusContainer) | ||
| { | ||
| _serviceBusContainer = serviceBusContainer; | ||
| } | ||
|
|
||
| public async ValueTask InitializeAsync() | ||
| { | ||
| await _serviceBusContainer.StartAsync() | ||
| .ConfigureAwait(false); | ||
| } | ||
|
|
||
| public async ValueTask DisposeAsync() | ||
| { | ||
| await DisposeAsyncCore() | ||
| .ConfigureAwait(false); | ||
|
|
||
| GC.SuppressFinalize(this); | ||
| } | ||
|
|
||
| protected virtual ValueTask DisposeAsyncCore() | ||
| { | ||
| return _serviceBusContainer.DisposeAsync(); | ||
| } | ||
|
|
||
|
|
||
|
NelsonBN marked this conversation as resolved.
Resolved
|
||
| [UsedImplicitly] | ||
| public sealed class ServiceBusDefaultMsSqlConfiguration : ServiceBusAdministrationClientTest | ||
| { | ||
| public ServiceBusDefaultMsSqlConfiguration() | ||
|
NelsonBN marked this conversation as resolved.
Resolved
|
||
| : base(new ServiceBusBuilder(TestSession.GetImageFromDockerfile()) | ||
| .WithAcceptLicenseAgreement(true) | ||
| .Build()) | ||
| { | ||
| } | ||
| } | ||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
|
||
|
|
||
|
|
||
|
NelsonBN marked this conversation as resolved.
Resolved
|
||
| [Fact] | ||
| [Trait(nameof(DockerCli.DockerPlatform), nameof(DockerCli.DockerPlatform.Linux))] | ||
| public async Task CreateQueueViaServiceBusAdministrationClient() | ||
| { | ||
| // Given | ||
| const string helloServiceBus = "Hello, Service Bus!"; | ||
| var queueName = $"sample-queue-{Guid.NewGuid()}"; | ||
|
|
||
| // By default, the emulator uses the following configuration: | ||
| // https://learn.microsoft.com/en-us/azure/service-bus-messaging/test-locally-with-service-bus-emulator?tabs=automated-script#interact-with-the-emulator. | ||
|
|
||
| var message = new ServiceBusMessage(helloServiceBus); | ||
|
|
||
| await using var client = new ServiceBusClient(_serviceBusContainer.GetConnectionString()); | ||
| var adminClient = new ServiceBusAdministrationClient(_serviceBusContainer.GetHttpConnectionString()); | ||
|
NelsonBN marked this conversation as resolved.
Resolved
|
||
|
|
||
| var sender = client.CreateSender(queueName); | ||
|
|
||
| var receiver = client.CreateReceiver(queueName); | ||
|
NelsonBN marked this conversation as resolved.
Resolved
|
||
|
|
||
| // When | ||
| await adminClient.CreateQueueAsync(new CreateQueueOptions(queueName), TestContext.Current.CancellationToken) | ||
| .ConfigureAwait(true); | ||
|
|
||
| await sender.SendMessageAsync(message, TestContext.Current.CancellationToken) | ||
| .ConfigureAwait(true); | ||
|
|
||
| var receivedMessage = await receiver.ReceiveMessageAsync(cancellationToken: TestContext.Current.CancellationToken) | ||
| .ConfigureAwait(true); | ||
|
|
||
| // Then | ||
| Assert.Equal(helloServiceBus, receivedMessage.Body.ToString()); | ||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
|
||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.