Skip to content

Commit 5db751f

Browse files
committed
Renamed configuration property names per review feedback.
1 parent 71fb4f7 commit 5db751f

File tree

5 files changed

+42
-39
lines changed

5 files changed

+42
-39
lines changed

Reqnroll/Formatters/Configuration/FormattersConfigurationResolverBase.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ namespace Reqnroll.Formatters.Configuration;
88
public abstract class FormattersConfigurationResolverBase : IFormattersConfigurationResolverBase
99
{
1010
protected const string FORMATTERS_KEY = "formatters";
11+
public const string ATTACHMENT_HANDLING_SECTION = "attachmentHandling";
12+
public const string ATTACHMENT_HANDLING_MODE = "mode";
13+
public const string ATTACHMENT_EXTERNAL_STORAGE_PATH = "attachmentsStoragePath";
1114

1215
public IDictionary<string, IDictionary<string, object>> Resolve()
1316
{
@@ -45,19 +48,19 @@ protected virtual void ProcessJsonDocument(JsonDocument jsonDocument, Dictionary
4548
private object GetConfigValue(JsonElement element, string propertyName = null)
4649
{
4750
// Check if this property is the AttachmentHandlingOptions section
48-
if (propertyName != null && propertyName.Equals("attachmentHandlingOptions", StringComparison.OrdinalIgnoreCase) &&
51+
if (propertyName != null && propertyName.Equals(ATTACHMENT_HANDLING_SECTION, StringComparison.OrdinalIgnoreCase) &&
4952
element.ValueKind == JsonValueKind.Object)
5053
{
5154
var dict = GetConfigValue(element) as IDictionary<string, object>;
5255
if (dict != null)
5356
{
5457
AttachmentHandlingOption attachmentHandlingOption = AttachmentHandlingOption.None;
5558
string externalPath = null;
56-
if (dict.TryGetValue("attachmentHandling", out var handlingObj) && handlingObj is AttachmentHandlingOption)
59+
if (dict.TryGetValue(ATTACHMENT_HANDLING_MODE, out var handlingObj) && handlingObj is AttachmentHandlingOption)
5760
{
5861
attachmentHandlingOption = (AttachmentHandlingOption)handlingObj;
5962
}
60-
if (dict.TryGetValue("externalAttachmentsStoragePath", out var pathObj) && pathObj is string pathStr)
63+
if (dict.TryGetValue(ATTACHMENT_EXTERNAL_STORAGE_PATH, out var pathObj) && pathObj is string pathStr)
6164
{
6265
externalPath = pathStr;
6366
}
@@ -89,7 +92,7 @@ protected virtual bool TryParseAsEnum(JsonElement element, string propertyName,
8992
{
9093
enumValue = null;
9194

92-
if (propertyName.Equals("attachmentHandling", StringComparison.OrdinalIgnoreCase) &&
95+
if (propertyName.Equals(ATTACHMENT_HANDLING_MODE, StringComparison.OrdinalIgnoreCase) &&
9396
element.ValueKind == JsonValueKind.String)
9497
{
9598
var stringValue = element.GetString();

Reqnroll/Formatters/FormatterBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ bool IsFormatterEnabled(out IDictionary<string, object> configuration)
8181

8282
public virtual AttachmentHandlingOptions GetAttachmentHandlingOptionValues(IDictionary<string, object> formatterConfiguration)
8383
{
84-
if (formatterConfiguration.TryGetValue("attachmentHandlingOptions", out var options)
84+
if (formatterConfiguration.TryGetValue(FormattersConfigurationResolverBase.ATTACHMENT_HANDLING_SECTION, out var options)
8585
&& options is AttachmentHandlingOptions attachmentHandlingOptions)
8686
{
8787
_logger.WriteMessage($"DEBUG: Formatters: Formatter plugin: {Name} setting AttachmentHandlingOption to {attachmentHandlingOptions.AttachmentHandlingOption.ToString()} from configuration.");

Tests/Reqnroll.Formatters.Tests/reqnroll_withExternalAttachments.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
"formatters": {
77
"message": {
88
"outputFilePath": "[BaseDirectory]/CucumberMessages/reqnroll_externalAttachments_report.ndjson",
9-
"attachmentHandlingOptions": {
10-
"attachmentHandling": "External",
11-
"externalAttachmentsStoragePath": "path/to/CucumberMessages/Attachments"
9+
"attachmentHandling": {
10+
"mode": "External",
11+
"attachmentsStoragePath": "path/to/CucumberMessages/Attachments"
1212
}
1313
}
1414
}

Tests/Reqnroll.RuntimeTests/Formatters/Configuration/FileBasedConfigurationResolverTests.cs

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -199,15 +199,15 @@ public void Resolve_Should_Return_Formatter_Of_Multiple_Levels_Of_Settings()
199199

200200

201201
[Fact]
202-
public void Resolve_Should_Parse_AttachmentHandling_As_Enum_Embed()
202+
public void Resolve_Should_Parse_AttachmentHandling_Mode_As_Enum_Embed()
203203
{
204204
// Arrange
205205
var filePath = "config.json";
206206
var fileContent = @"
207207
{
208208
""formatters"": {
209209
""cucumberMessages"": {
210-
""attachmentHandling"": ""Embed""
210+
""mode"": ""Embed""
211211
}
212212
}
213213
}";
@@ -221,19 +221,19 @@ public void Resolve_Should_Parse_AttachmentHandling_As_Enum_Embed()
221221

222222
// Assert
223223
result.Should().HaveCount(1);
224-
result["cucumberMessages"]["attachmentHandling"].Should().Be(AttachmentHandlingOption.Embed);
224+
result["cucumberMessages"]["mode"].Should().Be(AttachmentHandlingOption.Embed);
225225
}
226226

227227
[Fact]
228-
public void Resolve_Should_Parse_AttachmentHandling_As_Enum_External()
228+
public void Resolve_Should_Parse_AttachmentHandling_Mode_As_Enum_External()
229229
{
230230
// Arrange
231231
var filePath = "config.json";
232232
var fileContent = @"
233233
{
234234
""formatters"": {
235235
""cucumberMessages"": {
236-
""attachmentHandling"": ""External""
236+
""mode"": ""External""
237237
}
238238
}
239239
}";
@@ -247,19 +247,19 @@ public void Resolve_Should_Parse_AttachmentHandling_As_Enum_External()
247247

248248
// Assert
249249
result.Should().HaveCount(1);
250-
result["cucumberMessages"]["attachmentHandling"].Should().Be(AttachmentHandlingOption.External);
250+
result["cucumberMessages"]["mode"].Should().Be(AttachmentHandlingOption.External);
251251
}
252252

253253
[Fact]
254-
public void Resolve_Should_Parse_AttachmentHandling_As_Enum_None()
254+
public void Resolve_Should_Parse_AttachmentHandling_Mode_As_Enum_None()
255255
{
256256
// Arrange
257257
var filePath = "config.json";
258258
var fileContent = @"
259259
{
260260
""formatters"": {
261261
""cucumberMessages"": {
262-
""attachmentHandling"": ""None""
262+
""mode"": ""None""
263263
}
264264
}
265265
}";
@@ -273,19 +273,19 @@ public void Resolve_Should_Parse_AttachmentHandling_As_Enum_None()
273273

274274
// Assert
275275
result.Should().HaveCount(1);
276-
result["cucumberMessages"]["attachmentHandling"].Should().Be(AttachmentHandlingOption.None);
276+
result["cucumberMessages"]["mode"].Should().Be(AttachmentHandlingOption.None);
277277
}
278278

279279
[Fact(Skip = "Skip while deciding on proper behavior for invalid configurations")]
280-
public void Resolve_Should_Parse_AttachmentHandling_CaseInsensitive()
280+
public void Resolve_Should_Parse_AttachmentHandling_Mode_CaseInsensitive()
281281
{
282282
// Arrange
283283
var filePath = "config.json";
284284
var fileContent = @"
285285
{
286286
""formatters"": {
287287
""cucumberMessages"": {
288-
""attachmentHandling"": ""embed""
288+
""mode"": ""embed""
289289
}
290290
}
291291
}";
@@ -299,19 +299,19 @@ public void Resolve_Should_Parse_AttachmentHandling_CaseInsensitive()
299299

300300
// Assert
301301
result.Should().HaveCount(1);
302-
result["cucumberMessages"]["attachmentHandling"].Should().Be(AttachmentHandlingOption.Embed);
302+
result["cucumberMessages"]["mode"].Should().Be(AttachmentHandlingOption.Embed);
303303
}
304304

305305
[Fact]
306-
public void Resolve_Should_Keep_String_When_AttachmentHandling_Value_Is_Invalid()
306+
public void Resolve_Should_Keep_String_When_AttachmentHandling_Mode_Value_Is_Invalid()
307307
{
308308
// Arrange
309309
var filePath = "config.json";
310310
var fileContent = @"
311311
{
312312
""formatters"": {
313313
""cucumberMessages"": {
314-
""attachmentHandling"": ""INVALID_VALUE""
314+
""mode"": ""INVALID_VALUE""
315315
}
316316
}
317317
}";
@@ -325,11 +325,11 @@ public void Resolve_Should_Keep_String_When_AttachmentHandling_Value_Is_Invalid(
325325

326326
// Assert
327327
result.Should().HaveCount(1);
328-
result["cucumberMessages"]["attachmentHandling"].Should().Be("INVALID_VALUE");
328+
result["cucumberMessages"]["mode"].Should().Be("INVALID_VALUE");
329329
}
330330

331331
[Fact]
332-
public void Resolve_Should_Parse_AttachmentHandling_In_Nested_Configuration()
332+
public void Resolve_Should_Parse_AttachmentHandling_Mode_In_Nested_Configuration()
333333
{
334334
// Arrange
335335
var filePath = "config.json";
@@ -338,7 +338,7 @@ public void Resolve_Should_Parse_AttachmentHandling_In_Nested_Configuration()
338338
""formatters"": {
339339
""cucumberMessages"": {
340340
""outputPath"": ""output/results.ndjson"",
341-
""attachmentHandling"": ""External"",
341+
""mode"": ""External"",
342342
""otherSettings"": {
343343
""enabled"": true
344344
}
@@ -356,7 +356,7 @@ public void Resolve_Should_Parse_AttachmentHandling_In_Nested_Configuration()
356356
// Assert
357357
result.Should().HaveCount(1);
358358
result["cucumberMessages"]["outputPath"].Should().Be("output/results.ndjson");
359-
result["cucumberMessages"]["attachmentHandling"].Should().Be(AttachmentHandlingOption.External);
359+
result["cucumberMessages"]["mode"].Should().Be(AttachmentHandlingOption.External);
360360

361361
var otherSettings = result["cucumberMessages"]["otherSettings"];
362362
otherSettings.Should().BeOfType<Dictionary<string, object>>();
@@ -373,10 +373,10 @@ public void Resolve_Should_Parse_Multiple_Formatters_With_Different_AttachmentHa
373373
{
374374
""formatters"": {
375375
""formatter1"": {
376-
""attachmentHandling"": ""Embed""
376+
""mode"": ""Embed""
377377
},
378378
""formatter2"": {
379-
""attachmentHandling"": ""External""
379+
""mode"": ""External""
380380
}
381381
}
382382
}";
@@ -390,8 +390,8 @@ public void Resolve_Should_Parse_Multiple_Formatters_With_Different_AttachmentHa
390390

391391
// Assert
392392
result.Should().HaveCount(2);
393-
result["formatter1"]["attachmentHandling"].Should().Be(AttachmentHandlingOption.Embed);
394-
result["formatter2"]["attachmentHandling"].Should().Be(AttachmentHandlingOption.External);
393+
result["formatter1"]["mode"].Should().Be(AttachmentHandlingOption.Embed);
394+
result["formatter2"]["mode"].Should().Be(AttachmentHandlingOption.External);
395395
}
396396

397397
[Fact]
@@ -403,9 +403,9 @@ public void Resolve_Should_Parse_Formatter_With_AttachmentOptions()
403403
{
404404
""formatters"": {
405405
""formatter1"": {
406-
""attachmentHandlingOptions"": {
407-
""attachmentHandling"": ""External"",
408-
""externalAttachmentsStoragePath"": ""/path/to/attachments""
406+
""attachmentHandling"": {
407+
""mode"": ""External"",
408+
""attachmentsStoragePath"": ""/path/to/attachments""
409409
}
410410
}
411411
}
@@ -419,8 +419,8 @@ public void Resolve_Should_Parse_Formatter_With_AttachmentOptions()
419419
var result = _sut.Resolve();
420420

421421
// Assert
422-
result["formatter1"]["attachmentHandlingOptions"].Should().BeOfType<AttachmentHandlingOptions>();
423-
var attachmentOptions = (AttachmentHandlingOptions)result["formatter1"]["attachmentHandlingOptions"];
422+
result["formatter1"]["attachmentHandling"].Should().BeOfType<AttachmentHandlingOptions>();
423+
var attachmentOptions = (AttachmentHandlingOptions)result["formatter1"]["attachmentHandling"];
424424
attachmentOptions.AttachmentHandlingOption.Should().Be(AttachmentHandlingOption.External);
425425
attachmentOptions.ExternalAttachmentsStoragePath.Should().Be("/path/to/attachments");
426426
}

reqnroll-config.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@
141141
"type": "string",
142142
"description": "File path where the HTML report will be output."
143143
},
144-
"attachmentHandlingOptions": {
144+
"attachmentHandling": {
145145
"$ref": "#/definitions/FormatterAttachmentHandlingOptions"
146146
}
147147
},
@@ -155,7 +155,7 @@
155155
"type": "string",
156156
"description": "File path where the message ndjson output will be saved."
157157
},
158-
"attachmentHandlingOptions": {
158+
"attachmentHandling": {
159159
"$ref": "#/definitions/FormatterAttachmentHandlingOptions"
160160
}
161161
},
@@ -334,13 +334,13 @@
334334
"type": "object",
335335
"additionalProperties": true,
336336
"properties": {
337-
"attachmentHandling": {
337+
"mode": {
338338
"description": "Specifies how attachments will be reported.",
339339
"type": "string",
340340
"default": "Embed",
341341
"enum": [ "None", "Embed", "External" ]
342342
},
343-
"externalAttachmentsStoragePath": {
343+
"attachmentsStoragePath": {
344344
"description": "The file system path where external attachments will be stored by the executing test framework. This setting is required if 'attachmentHandling' is set to 'External'.",
345345
"type": "string"
346346
}

0 commit comments

Comments
 (0)