-
-
Notifications
You must be signed in to change notification settings - Fork 300
/
Copy pathAzuriteContainer.cs
58 lines (53 loc) · 2.09 KB
/
AzuriteContainer.cs
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
47
48
49
50
51
52
53
54
55
56
57
58
namespace Testcontainers.Azurite;
/// <inheritdoc cref="DockerContainer" />
[PublicAPI]
public sealed class AzuriteContainer : DockerContainer
{
/// <summary>
/// Initializes a new instance of the <see cref="AzuriteContainer" /> class.
/// </summary>
/// <param name="configuration">The container configuration.</param>
public AzuriteContainer(AzuriteConfiguration configuration)
: base(configuration)
{
}
/// <summary>
/// Gets the Azurite connection string.
/// </summary>
/// <returns>The Azurite connection string.</returns>
public string GetConnectionString()
{
var properties = new Dictionary<string, string>();
properties.Add("DefaultEndpointsProtocol", Uri.UriSchemeHttp);
properties.Add("AccountName", AzuriteBuilder.AccountName);
properties.Add("AccountKey", AzuriteBuilder.AccountKey);
properties.Add("BlobEndpoint", GetBlobEndpoint());
properties.Add("QueueEndpoint", GetQueueEndpoint());
properties.Add("TableEndpoint", GetTableEndpoint());
return string.Join(";", properties.Select(property => string.Join("=", property.Key, property.Value)));
}
/// <summary>
/// Gets the blob endpoint
/// </summary>
/// <returns>The Azurite blob endpoint</returns>
public string GetBlobEndpoint()
{
return new UriBuilder(Uri.UriSchemeHttp, Hostname, GetMappedPublicPort(AzuriteBuilder.BlobPort), AzuriteBuilder.AccountName).ToString();
}
/// <summary>
/// Gets the queue endpoint
/// </summary>
/// <returns>The Azurite queue endpoint</returns>
public string GetQueueEndpoint()
{
return new UriBuilder(Uri.UriSchemeHttp, Hostname, GetMappedPublicPort(AzuriteBuilder.QueuePort), AzuriteBuilder.AccountName).ToString();
}
/// <summary>
/// Gets the table endpoint
/// </summary>
/// <returns>The Azurite table endpoint</returns>
public string GetTableEndpoint()
{
return new UriBuilder(Uri.UriSchemeHttp, Hostname, GetMappedPublicPort(AzuriteBuilder.TablePort), AzuriteBuilder.AccountName).ToString();
}
}