Skip to content

Commit ce7627f

Browse files
committed
.
1 parent 8c88939 commit ce7627f

File tree

4 files changed

+23
-6
lines changed

4 files changed

+23
-6
lines changed

src/WireMock.Net.Testcontainers/WireMockConfiguration.cs

+14-2
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ public WireMockConfiguration(WireMockConfiguration oldValue, WireMockConfigurati
7777
StaticMappingsPath = BuildConfiguration.Combine(oldValue.StaticMappingsPath, newValue.StaticMappingsPath);
7878
WatchStaticMappings = BuildConfiguration.Combine(oldValue.WatchStaticMappings, newValue.WatchStaticMappings);
7979
WatchStaticMappingsInSubdirectories = BuildConfiguration.Combine(oldValue.WatchStaticMappingsInSubdirectories, newValue.WatchStaticMappingsInSubdirectories);
80-
AdditionalUrls = BuildConfiguration.Combine(oldValue.AdditionalUrls.AsEnumerable(), newValue.AdditionalUrls.AsEnumerable()).ToList();
81-
ProtoDefinitions = BuildConfiguration.Combine(oldValue.ProtoDefinitions, newValue.ProtoDefinitions);
80+
AdditionalUrls = Combine(oldValue.AdditionalUrls, newValue.AdditionalUrls);
81+
ProtoDefinitions = Combine(oldValue.ProtoDefinitions, newValue.ProtoDefinitions);
8282
}
8383

8484
/// <summary>
@@ -130,4 +130,16 @@ public WireMockConfiguration AddProtoDefinition(string id, params string[] proto
130130

131131
return this;
132132
}
133+
134+
private static List<T> Combine<T>(List<T> oldValue, List<T> newValue)
135+
{
136+
return oldValue.Concat(newValue).ToList();
137+
}
138+
139+
private static Dictionary<TKey, TValue> Combine<TKey, TValue>(Dictionary<TKey, TValue> oldValue, Dictionary<TKey, TValue> newValue)
140+
{
141+
return newValue
142+
.Concat(oldValue.Where(item => !newValue.Keys.Contains(item.Key)))
143+
.ToDictionary(item => item.Key, item => item.Value);
144+
}
133145
}

src/WireMock.Net.Testcontainers/WireMockContainer.cs

+7-2
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,13 @@ private async Task WireMockContainerStartedAsync(object sender, EventArgs e)
198198
{
199199
_adminApi = CreateWireMockAdminClient();
200200

201+
RegisterEnhancedFileSystemWatcher();
202+
203+
await CallAdditionalActionsAfterStartedAsync();
204+
}
205+
206+
private void RegisterEnhancedFileSystemWatcher()
207+
{
201208
if (!_configuration.WatchStaticMappings || string.IsNullOrEmpty(_configuration.StaticMappingsPath))
202209
{
203210
return;
@@ -211,8 +218,6 @@ private async Task WireMockContainerStartedAsync(object sender, EventArgs e)
211218
_enhancedFileSystemWatcher.Changed += FileCreatedChangedOrDeleted;
212219
_enhancedFileSystemWatcher.Deleted += FileCreatedChangedOrDeleted;
213220
_enhancedFileSystemWatcher.EnableRaisingEvents = true;
214-
215-
await CallAdditionalActionsAfterStartedAsync();
216221
}
217222

218223
private async Task CallAdditionalActionsAfterStartedAsync()

test/WireMock.Net.Tests/__admin/mappings/protobuf-mapping-2.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
},
3232
"Response": {
3333
"BodyAsJson": {
34-
"message": "hello {{request.BodyAsJson.name}}"
34+
"message": "hello {{request.BodyAsJson.name}} {{request.method}}"
3535
},
3636
"UseTransformer": true,
3737
"TransformerType": "Handlebars",

test/WireMock.Net.Tests/__admin/mappings/protobuf-mapping-4.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
},
2424
"Response": {
2525
"BodyAsJson": {
26-
"message": "hello {{request.BodyAsJson.name}}"
26+
"message": "hello {{request.BodyAsJson.name}} {{request.method}}"
2727
},
2828
"UseTransformer": true,
2929
"TransformerType": "Handlebars",

0 commit comments

Comments
 (0)