forked from testcontainers/testcontainers-dotnet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathServiceBusContainer.cs
More file actions
46 lines (43 loc) · 1.96 KB
/
ServiceBusContainer.cs
File metadata and controls
46 lines (43 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
namespace Testcontainers.ServiceBus;
/// <inheritdoc cref="DockerContainer" />
[PublicAPI]
public sealed class ServiceBusContainer : DockerContainer
{
/// <summary>
/// Initializes a new instance of the <see cref="ServiceBusContainer" /> class.
/// </summary>
/// <param name="configuration">The container configuration.</param>
public ServiceBusContainer(ServiceBusConfiguration configuration)
: base(configuration)
{
}
/// <summary>
/// Gets the Service Bus connection string.
/// </summary>
/// <returns>The Service Bus connection string.</returns>
public string GetConnectionString()
{
var properties = new Dictionary<string, string>();
properties.Add("Endpoint", new UriBuilder("amqp", Hostname, GetMappedPublicPort(ServiceBusBuilder.ServiceBusPort)).ToString());
properties.Add("SharedAccessKeyName", "RootManageSharedAccessKey");
properties.Add("SharedAccessKey", "SAS_KEY_VALUE");
properties.Add("UseDevelopmentEmulator", "true");
return string.Join(";", properties.Select(property => string.Join("=", property.Key, property.Value)));
}
/// <summary>
/// Gets the Service Bus HTTP connection string.
/// </summary>
/// <remarks>
/// This connection string is intended for use with the ServiceBusAdministrationClient.
/// </remarks>
/// <returns>The Service Bus HTTP connection string.</returns>
public string GetHttpConnectionString()
{
var properties = new Dictionary<string, string>();
properties.Add("Endpoint", new UriBuilder("sb", Hostname, GetMappedPublicPort(ServiceBusBuilder.ServiceBusHttpPort)).ToString());
properties.Add("SharedAccessKeyName", "RootManageSharedAccessKey");
properties.Add("SharedAccessKey", "SAS_KEY_VALUE");
properties.Add("UseDevelopmentEmulator", "true");
return string.Join(";", properties.Select(property => string.Join("=", property.Key, property.Value)));
}
}