Skip to content

Commit ccc5554

Browse files
committed
Implemented more expressive test names
For consistency with e.g. `AttributeValueCollectionTest` and `ITopicRepositoryTest`, updated the test namesin `ReverseTopicMappingServiceTest` to be more expressive using the format `METHOD_CONDITION_RESULT` (e.g., `Map_NullProperty_MapsDefaultValue()`).
1 parent 89359a7 commit ccc5554

1 file changed

Lines changed: 52 additions & 52 deletions

File tree

OnTopic.Tests/ReverseTopicMappingServiceTest.cs

Lines changed: 52 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,14 @@ public ReverseReverseTopicMappingServiceTest() {
5454
}
5555

5656
/*==========================================================================================================================
57-
| TEST: MAP (GENERIC)
57+
| TEST: MAP: GENERIC: RETURNS NEW TOPIC
5858
\-------------------------------------------------------------------------------------------------------------------------*/
5959
/// <summary>
6060
/// Establishes a <see cref="ReverseTopicMappingService"/> and tests setting basic scalar values by specifying an explicit
6161
/// type.
6262
/// </summary>
6363
[TestMethod]
64-
public async Task MapGeneric() {
64+
public async Task Map_Generic_ReturnsNewTopic() {
6565

6666
var mappingService = new ReverseTopicMappingService(_topicRepository);
6767

@@ -84,14 +84,14 @@ public async Task MapGeneric() {
8484
}
8585

8686
/*==========================================================================================================================
87-
| TEST: MAP (DYNAMIC)
87+
| TEST: MAP: DYNAMIC: RETURNS NEW TOPIC
8888
\-------------------------------------------------------------------------------------------------------------------------*/
8989
/// <summary>
9090
/// Establishes a <see cref="ReverseTopicMappingService"/> and tests setting basic scalar values by allowing it to
9191
/// dynamically determine the instance type.
9292
/// </summary>
9393
[TestMethod]
94-
public async Task MapDynamic() {
94+
public async Task Map_Dynamic_ReturnsNewTopic() {
9595

9696
var mappingService = new ReverseTopicMappingService(_topicRepository);
9797

@@ -115,14 +115,14 @@ public async Task MapDynamic() {
115115
}
116116

117117
/*==========================================================================================================================
118-
| TEST: MAP (EXISTING)
118+
| TEST: MAP: EXISTING: RETURNS UPDATED TOPIC
119119
\-------------------------------------------------------------------------------------------------------------------------*/
120120
/// <summary>
121121
/// Establishes a <see cref="ReverseTopicMappingService"/> and tests setting basic scalar values on an existing object,
122122
/// ensuring that all mapped values are overwritten, and unmapped valued are not.
123123
/// </summary>
124124
[TestMethod]
125-
public async Task MapExisting() {
125+
public async Task Map_Existing_ReturnsUpdatedTopic() {
126126

127127
var mappingService = new ReverseTopicMappingService(_topicRepository);
128128

@@ -155,13 +155,13 @@ public async Task MapExisting() {
155155
}
156156

157157
/*==========================================================================================================================
158-
| TEST: MAP COMPLEX OBJECTS
158+
| TEST: MAP: COMPLEX OBJECT: RETURNS FLATTENED TOPIC
159159
\-------------------------------------------------------------------------------------------------------------------------*/
160160
/// <summary>
161161
/// Establishes a <see cref="ReverseTopicMappingService"/> and tests setting values from complex objects.
162162
/// </summary>
163163
[TestMethod]
164-
public async Task MapComplexObjects() {
164+
public async Task Map_ComplexObject_ReturnsFlattenedTopic() {
165165

166166
var mappingService = new ReverseTopicMappingService(_topicRepository);
167167

@@ -184,14 +184,14 @@ public async Task MapComplexObjects() {
184184
}
185185

186186
/*==========================================================================================================================
187-
| TEST: ALTERNATE ATTRIBUTE KEY
187+
| TEST: MAP: ALTERNATE ATTRIBUTE KEY: RETURNS MAPPED TOPIC
188188
\-------------------------------------------------------------------------------------------------------------------------*/
189189
/// <summary>
190190
/// Establishes a <see cref="ReverseTopicMappingService"/> and tests whether it successfully derives values from the key
191191
/// specified by <see cref="AttributeKeyAttribute"/>.
192192
/// </summary>
193193
[TestMethod]
194-
public async Task AlternateAttributeKey() {
194+
public async Task Map_AlternateAttributeKey_ReturnsMappedTopic() {
195195

196196
var mappingService = new ReverseTopicMappingService(_topicRepository);
197197

@@ -209,13 +209,13 @@ public async Task AlternateAttributeKey() {
209209
}
210210

211211
/*==========================================================================================================================
212-
| TEST: MAP RELATIONSHIPS
212+
| TEST: MAP: RELATIONSHIPS: RETURNS MAPPED TOPIC
213213
\-------------------------------------------------------------------------------------------------------------------------*/
214214
/// <summary>
215215
/// Establishes a <see cref="ReverseTopicMappingService"/> and tests whether it successfully crawls the relationships.
216216
/// </summary>
217217
[TestMethod]
218-
public async Task MapRelationships() {
218+
public async Task Map_Relationships_ReturnsMappedTopic() {
219219

220220
var mappingService = new ReverseTopicMappingService(_topicRepository);
221221
var bindingModel = new ContentTypeDescriptorTopicBindingModel("Test");
@@ -243,13 +243,13 @@ public async Task MapRelationships() {
243243
}
244244

245245
/*==========================================================================================================================
246-
| TEST: MAP NESTED TOPICS
246+
| TEST: MAP: NESTED TOPICS: RETURNS MAPPED TOPIC
247247
\-------------------------------------------------------------------------------------------------------------------------*/
248248
/// <summary>
249249
/// Establishes a <see cref="ReverseTopicMappingService"/> and tests whether it successfully crawls the nested topics.
250250
/// </summary>
251251
[TestMethod]
252-
public async Task MapNestedTopics() {
252+
public async Task Map_NestedTopics_ReturnsMappedTopic() {
253253

254254
var mappingService = new ReverseTopicMappingService(_topicRepository);
255255
var bindingModel = new ContentTypeDescriptorTopicBindingModel("Test");
@@ -278,13 +278,13 @@ public async Task MapNestedTopics() {
278278
}
279279

280280
/*==========================================================================================================================
281-
| TEST: MAP TOPIC REFERENCES
281+
| TEST: MAP: TOPIC REFERENCES: RETURNS MAPPED TOPIC
282282
\-------------------------------------------------------------------------------------------------------------------------*/
283283
/// <summary>
284284
/// Establishes a <see cref="ReverseTopicMappingService"/> and tests whether it successfully maps referenced topics.
285285
/// </summary>
286286
[TestMethod]
287-
public async Task MapTopicReferences() {
287+
public async Task Map_TopicReferences_ReturnsMappedTopic() {
288288

289289
var mappingService = new ReverseTopicMappingService(_topicRepository);
290290

@@ -304,14 +304,14 @@ public async Task MapTopicReferences() {
304304
}
305305

306306
/*==========================================================================================================================
307-
| TEST: MAP REQUIRED PROPERTY
307+
| TEST: MAP: VALID REQUIRED PROPERTY: IS MAPPED
308308
\-------------------------------------------------------------------------------------------------------------------------*/
309309
/// <summary>
310310
/// Maps a content type that has a required property. Ensures that an error is thrown if it is not set.
311311
/// </summary>
312312
[TestMethod]
313313
[ExpectedException(typeof(ValidationException))]
314-
public async Task MapRequiredProperty() {
314+
public async Task Map_ValidRequiredProperty_IsMapped() {
315315

316316
var mappingService = new ReverseTopicMappingService(_topicRepository);
317317
var bindingModel = new PageTopicBindingModel("Test");
@@ -321,13 +321,13 @@ public async Task MapRequiredProperty() {
321321
}
322322

323323
/*==========================================================================================================================
324-
| TEST: DEFAULT VALUE PROPERTIES
324+
| TEST: MAP: NULL PROPERTY: MAPS DEFAULT VALUE
325325
\-------------------------------------------------------------------------------------------------------------------------*/
326326
/// <summary>
327327
/// Maps a content type that has default properties. Ensures that each is set appropriately.
328328
/// </summary>
329329
[TestMethod]
330-
public async Task MapDefaultValueProperties() {
330+
public async Task Map_NullProperty_MapsDefaultValue() {
331331

332332
var mappingService = new ReverseTopicMappingService(_topicRepository);
333333

@@ -342,14 +342,14 @@ public async Task MapDefaultValueProperties() {
342342
}
343343

344344
/*==========================================================================================================================
345-
| TEST: MINIMUM VALUE PROPERTIES
345+
| TEST: MAP: EXCEEDS MINIMUM VALUE: THROWS VALIDATION EXCEPTION
346346
\-------------------------------------------------------------------------------------------------------------------------*/
347347
/// <summary>
348348
/// Maps a content type that has minimum value properties. Ensures that an error is thrown if the minimum is not met.
349349
/// </summary>
350350
[TestMethod]
351351
[ExpectedException(typeof(ValidationException))]
352-
public async Task MapMinimumValueProperties() {
352+
public async Task Map_ExceedsMinimumValue_ThrowsValidationException() {
353353

354354
var mappingService = new ReverseTopicMappingService(_topicRepository);
355355

@@ -362,15 +362,15 @@ public async Task MapMinimumValueProperties() {
362362
}
363363

364364
/*==========================================================================================================================
365-
| TEST: CHILDREN PROPERTY (INVALID)
365+
| TEST: MAP: INVALID CHILDREN PROPERTY: THROWS INVALID OPERATION EXCEPTION
366366
\-------------------------------------------------------------------------------------------------------------------------*/
367367
/// <summary>
368368
/// Maps a content type that has children property. This is invalid, and expected to throw an <see
369369
/// cref="InvalidOperationException"/>.
370370
/// </summary>
371371
[TestMethod]
372372
[ExpectedException(typeof(InvalidOperationException))]
373-
public async Task InvalidChildrenProperty() {
373+
public async Task Map_InvalidChildrenProperty_ThrowsInvalidOperationException() {
374374

375375
var mappingService = new ReverseTopicMappingService(_topicRepository);
376376
var bindingModel = new InvalidChildrenTopicBindingModel("Test");
@@ -380,15 +380,15 @@ public async Task InvalidChildrenProperty() {
380380
}
381381

382382
/*==========================================================================================================================
383-
| TEST: PARENT PROPERTY (INVALID)
383+
| TEST: MAP: INVALID PARENT PROPERTY: THROWS INVALID OPERATION EXCEPTION
384384
\-------------------------------------------------------------------------------------------------------------------------*/
385385
/// <summary>
386386
/// Maps a content type that has parent property. This is invalid, and expected to throw an <see
387387
/// cref="InvalidOperationException"/>.
388388
/// </summary>
389389
[TestMethod]
390390
[ExpectedException(typeof(InvalidOperationException))]
391-
public async Task InvalidParentProperty() {
391+
public async Task Map_InvalidParentProperty_ThrowsInvalidOperationException() {
392392

393393
var mappingService = new ReverseTopicMappingService(_topicRepository);
394394

@@ -401,15 +401,15 @@ public async Task InvalidParentProperty() {
401401
}
402402

403403
/*==========================================================================================================================
404-
| TEST: ATTRIBUTE PROPERTY (INVALID)
404+
| TEST: MAP: INVALID ATTRIBUTE: THROWS INVALID OPERATION EXCEPTION
405405
\-------------------------------------------------------------------------------------------------------------------------*/
406406
/// <summary>
407407
/// Maps a content type that has a property that doesn't map to any attributes. This is invalid, and expected to throw an
408408
/// <see cref="InvalidOperationException"/>.
409409
/// </summary>
410410
[TestMethod]
411411
[ExpectedException(typeof(InvalidOperationException))]
412-
public async Task InvalidAttributeProperty() {
412+
public async Task Map_InvalidAttribute_ThrowsInvalidOperationException() {
413413

414414
var mappingService = new ReverseTopicMappingService(_topicRepository);
415415
var bindingModel = new InvalidAttributeTopicBindingModel("Test");
@@ -419,15 +419,15 @@ public async Task InvalidAttributeProperty() {
419419
}
420420

421421
/*==========================================================================================================================
422-
| TEST: RELATIONSHIP BASE TYPE PROPERTY (INVALID)
422+
| TEST: MAP: INVALID RELATIONSHIP BASE TYPE: THROWS INVALID OPERATION EXCEPTION
423423
\-------------------------------------------------------------------------------------------------------------------------*/
424424
/// <summary>
425425
/// Maps a content type that has a relationship whose type doesn't implement <see cref="IRelatedTopicBindingModel"/>. This
426426
/// is invalid, and expected to throw an <see cref="InvalidOperationException"/>.
427427
/// </summary>
428428
[TestMethod]
429429
[ExpectedException(typeof(InvalidOperationException))]
430-
public async Task InvalidRelationshipBaseTypeProperty() {
430+
public async Task Map_InvalidRelationshipBaseType_ThrowsInvalidOperationException() {
431431

432432
var mappingService = new ReverseTopicMappingService(_topicRepository);
433433
var bindingModel = new InvalidRelationshipBaseTypeTopicBindingModel("Test");
@@ -437,64 +437,64 @@ public async Task InvalidRelationshipBaseTypeProperty() {
437437
}
438438

439439
/*==========================================================================================================================
440-
| TEST: REFERENCE NAME PROPERTY (INVALID)
440+
| TEST: MAP: INVALID RELATIONSHIP TYPE: THROWS INVALID OPERATION EXCEPTION
441441
\-------------------------------------------------------------------------------------------------------------------------*/
442442
/// <summary>
443-
/// Maps a content type that has a reference that does not end in <c>Id</c>. This is invalid, and expected to throw an
444-
/// <see cref="InvalidOperationException"/>.
443+
/// Maps a content type that has a relationship an invalid <see cref="RelationshipType"/>—i.e., it refers to <see
444+
/// cref="RelationshipType.NestedTopics"/>, even though the property is associated with a <see
445+
/// cref="RelationshipType.Relationship"/>. This is invalid, and expected to throw an <see
446+
/// cref="InvalidOperationException"/>.
445447
/// </summary>
446448
[TestMethod]
447449
[ExpectedException(typeof(InvalidOperationException))]
448-
public async Task InvalidReferenceNameProperty() {
450+
public async Task Map_InvalidRelationshipType_ThrowsInvalidOperationException() {
449451

450452
var mappingService = new ReverseTopicMappingService(_topicRepository);
451-
var bindingModel = new InvalidReferenceNameTopicBindingModel("Test");
453+
var bindingModel = new InvalidRelationshipTypeTopicBindingModel("Test");
452454

453455
var target = await mappingService.MapAsync(bindingModel).ConfigureAwait(false);
454456

455457
}
456458

457459
/*==========================================================================================================================
458-
| TEST: RELATIONSHIP TYPE PROPERTY (INVALID)
460+
| TEST: MAP: INVALID RELATIONSHIP LIST TYPE: THROWS INVALID OPERATION EXCEPTION
459461
\-------------------------------------------------------------------------------------------------------------------------*/
460462
/// <summary>
461-
/// Maps a content type that has a relationship an invalid <see cref="RelationshipType"/>—i.e., it refers to <see
462-
/// cref="RelationshipType.NestedTopics"/>, even though the property is associated with a <see
463-
/// cref="RelationshipType.Relationship"/>. This is invalid, and expected to throw an <see
464-
/// cref="InvalidOperationException"/>.
463+
/// Maps a content type that has a relationship that implements an invalid collection type—i.e., it implements a <see
464+
/// cref="Dictionary{TKey, TValue}"/>, even though relationships are expected to return a type implementing <see
465+
/// cref="IList"/>. This is invalid, and expected to throw an <see cref="InvalidOperationException"/>.
465466
/// </summary>
466467
[TestMethod]
467468
[ExpectedException(typeof(InvalidOperationException))]
468-
public async Task InvalidRelationshipTypeProperty() {
469+
public async Task Map_InvalidRelationshipListType_ThrowsInvalidOperationException() {
469470

470471
var mappingService = new ReverseTopicMappingService(_topicRepository);
471-
var bindingModel = new InvalidRelationshipTypeTopicBindingModel("Test");
472+
var bindingModel = new InvalidRelationshipListTypeTopicBindingModel("Test");
472473

473474
var target = await mappingService.MapAsync(bindingModel).ConfigureAwait(false);
474475

475476
}
476477

477478
/*==========================================================================================================================
478-
| TEST: RELATIONSHIP LIST TYPE PROPERTY (INVALID)
479+
| TEST: MAP: INVALID TOPIC REFERENCE NAME: THROWS INVALID OPERATION EXCEPTION
479480
\-------------------------------------------------------------------------------------------------------------------------*/
480481
/// <summary>
481-
/// Maps a content type that has a relationship that implements an invalid collection type—i.e., it implements a <see
482-
/// cref="Dictionary{TKey, TValue}"/>, even though relationships are expected to return a type implementing <see
483-
/// cref="IList"/>. This is invalid, and expected to throw an <see cref="InvalidOperationException"/>.
482+
/// Maps a content type that has a reference that does not end in <c>Id</c>. This is invalid, and expected to throw an
483+
/// <see cref="InvalidOperationException"/>.
484484
/// </summary>
485485
[TestMethod]
486486
[ExpectedException(typeof(InvalidOperationException))]
487-
public async Task InvalidRelationshipListTypeProperty() {
487+
public async Task Map_InvalidTopicReferenceName_ThrowsInvalidOperationException() {
488488

489489
var mappingService = new ReverseTopicMappingService(_topicRepository);
490-
var bindingModel = new InvalidRelationshipListTypeTopicBindingModel("Test");
490+
var bindingModel = new InvalidReferenceNameTopicBindingModel("Test");
491491

492492
var target = await mappingService.MapAsync(bindingModel).ConfigureAwait(false);
493493

494494
}
495495

496496
/*==========================================================================================================================
497-
| TEST: REFERENCE TYPE PROPERTY (INVALID)
497+
| TEST: MAP: INVALID TOPIC REFERENCE TYPE: THROWS INVALID OPERATION EXCEPTION
498498
\-------------------------------------------------------------------------------------------------------------------------*/
499499
/// <summary>
500500
/// Maps a content type that has a reference that implements an invalid type—i.e., it implements a <see
@@ -503,7 +503,7 @@ public async Task InvalidRelationshipListTypeProperty() {
503503
/// </summary>
504504
[TestMethod]
505505
[ExpectedException(typeof(InvalidOperationException))]
506-
public async Task InvalidReferenceTypeProperty() {
506+
public async Task Map_InvalidTopicReferenceType_ThrowsInvalidOperationException() {
507507

508508
var mappingService = new ReverseTopicMappingService(_topicRepository);
509509
var bindingModel = new InvalidReferenceTypeTopicBindingModel("Test");
@@ -513,15 +513,15 @@ public async Task InvalidReferenceTypeProperty() {
513513
}
514514

515515
/*==========================================================================================================================
516-
| TEST: ATTRIBUTE PROPERTY (DISABLED)
516+
| TEST: MAP: DISABLED PROPERTY: IS NOT MAPPED
517517
\-------------------------------------------------------------------------------------------------------------------------*/
518518
/// <summary>
519519
/// Maps a content type that has a property that doesn't map to any attributes. This is invalid. However, the property
520520
/// is also decorated with the <see cref="DisableMappingAttribute"/>, which should prevent the <see
521521
/// cref="ReverseTopicMappingService"/> from validating or mapping the property.
522522
/// </summary>
523523
[TestMethod]
524-
public async Task DisabledAttributeProperty() {
524+
public async Task Map_DisabledProperty_IsNotMapped() {
525525

526526
var mappingService = new ReverseTopicMappingService(_topicRepository);
527527

0 commit comments

Comments
 (0)