Skip to content

Commit 7235caf

Browse files
committed
docs: add testcontainers [skip ci]
1 parent b129b3d commit 7235caf

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,3 +349,37 @@ services:
349349
- ./emulator.crt:/usr/local/share/azureappconfigurationemulator/emulator.crt:ro
350350
- ./emulator.key:/usr/local/share/azureappconfigurationemulator/emulator.key:ro
351351
```
352+
353+
## Testcontainers
354+
355+
The emulator integrates with [Testcontainers](https://testcontainers.org) to ease the integration testing of applications that use Azure App Configuration.
356+
357+
```csharp
358+
var container = new ContainerBuilder()
359+
.WithImage("tnc1997/azure-app-configuration-emulator:1.0")
360+
.WithPortBinding(8080, true)
361+
.WithWaitStrategy(Wait.ForUnixContainer().UntilMessageIsLogged("Now listening on"))
362+
.Build();
363+
364+
await container.StartAsync();
365+
366+
var client = new ConfigurationClient($"Endpoint={new UriBuilder(Uri.UriSchemeHttp, container.Hostname, container.GetMappedPublicPort(8080))};Id=abcd;Secret=c2VjcmV0");
367+
368+
await client.SetConfigurationSettingAsync(nameof(ConfigurationSetting.Key), nameof(ConfigurationSetting.Value));
369+
370+
var response = await client.GetConfigurationSettingAsync(nameof(ConfigurationSetting.Key));
371+
```
372+
373+
**Coming Soon** [testcontainers/testcontainers-dotnet#1198](https://github.com/testcontainers/testcontainers-dotnet/issues/1198)
374+
375+
```csharp
376+
var container = new AzureAppConfigurationBuilder().Build();
377+
378+
await container.StartAsync();
379+
380+
var client = new ConfigurationClient(container.GetConnectionString());
381+
382+
await client.SetConfigurationSettingAsync(nameof(ConfigurationSetting.Key), nameof(ConfigurationSetting.Value));
383+
384+
var response = await client.GetConfigurationSettingAsync(nameof(ConfigurationSetting.Key));
385+
```

0 commit comments

Comments
 (0)