Skip to content

Commit 4faee14

Browse files
committed
Implemented more expressive test names across AspNetCore tests
For consistency with `OnTopic.Tests`, updated the test names in `OnTopic.AspNetCore.Mvc.Tests` to be more expressive using the format `METHOD_CONDITION_RESULT` (e.g., ` Load_ByRoute_ReturnsTopic()`). In the case of the `ValidateTopicAttributeTest`, I excluded the `METHOD_` prefix due to length (e.g., `DisabledTopic_ReturnsNotFound`, instead of `OnActionExecuting_DisabledTopic_ReturnsNotFound`); the context should be implicit based on the class name.
1 parent 13673dd commit 4faee14

4 files changed

Lines changed: 24 additions & 24 deletions

File tree

OnTopic.AspNetCore.Mvc.Tests/TopicControllerTest.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,13 @@ public TopicControllerTest() {
7878
}
7979

8080
/*==========================================================================================================================
81-
| TEST: TOPIC
81+
| TEST: TOPIC CONTROLLER: INDEX ASYNC: RETURNS TOPIC VIEW RESULT
8282
\-------------------------------------------------------------------------------------------------------------------------*/
8383
/// <summary>
8484
/// Triggers the <see cref="TopicController.IndexAsync(String)" /> action.
8585
/// </summary>
8686
[TestMethod]
87-
public async Task TopicController_IndexAsync() {
87+
public async Task TopicController_IndexAsync_ReturnsTopicViewResult() {
8888

8989
var controller = new TopicController(_topicRepository, _topicMappingService) {
9090
ControllerContext = _context
@@ -101,13 +101,13 @@ public async Task TopicController_IndexAsync() {
101101
}
102102

103103
/*==========================================================================================================================
104-
| TEST: REDIRECT
104+
| TEST: REDIRECT CONTROLLER: REDIRECT: RETURNS REDIRECT RESULT
105105
\-------------------------------------------------------------------------------------------------------------------------*/
106106
/// <summary>
107107
/// Triggers the <see cref="FallbackController.Index()" /> action.
108108
/// </summary>
109109
[TestMethod]
110-
public void RedirectController_TopicRedirect() {
110+
public void RedirectController_TopicRedirect_ReturnsRedirectResult() {
111111

112112
var controller = new RedirectController(_topicRepository);
113113
var result = controller.Redirect(11110) as RedirectResult;
@@ -121,7 +121,7 @@ public void RedirectController_TopicRedirect() {
121121
}
122122

123123
/*==========================================================================================================================
124-
| TEST: SITEMAP
124+
| TEST: SITEMAP CONTROLLER: INDEX: RETURNS SITEMAP XML
125125
\-------------------------------------------------------------------------------------------------------------------------*/
126126
/// <summary>
127127
/// Triggers the index action of the <see cref="SitemapController.Index()" /> action.
@@ -133,7 +133,7 @@ public void RedirectController_TopicRedirect() {
133133
/// </remarks>
134134
[TestMethod]
135135
[ExpectedException(typeof(NullReferenceException), AllowDerivedTypes=false)]
136-
public void SitemapController_Index() {
136+
public void SitemapController_Index_ReturnsSitemapXml() {
137137

138138
var controller = new SitemapController(_topicRepository);
139139
var result = controller.Index() as ViewResult;

OnTopic.AspNetCore.Mvc.Tests/TopicRepositoryExtensionsTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@ public TopicRepositoryExtensionsTest() {
4343
}
4444

4545
/*==========================================================================================================================
46-
| TEST: LOAD (ROUTE)
46+
| TEST: LOAD: BY ROUTE: RETURNS TOPIC
4747
\-------------------------------------------------------------------------------------------------------------------------*/
4848
/// <summary>
4949
/// Establishes route data and ensures that a topic is correctly identified based on that route.
5050
/// </summary>
5151
[TestMethod]
52-
public void LoadRoute() {
52+
public void Load_ByRoute_ReturnsTopic() {
5353

5454
var routes = new RouteData();
5555
var topic = _topicRepository.Load("Root:Web:Web_0:Web_0_1:Web_0_1_1");

OnTopic.AspNetCore.Mvc.Tests/TopicViewComponentTest.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,13 @@ public TopicViewComponentTest() {
9797
}
9898

9999
/*==========================================================================================================================
100-
| TEST: MENU
100+
| TEST: MENU: INVOKE: RETURNS NAVIGATION VIEW MODEL
101101
\-------------------------------------------------------------------------------------------------------------------------*/
102102
/// <summary>
103103
/// Loads a new <see cref="MenuViewComponent"/> and confirms the resulting values.
104104
/// </summary>
105105
[TestMethod]
106-
public async Task Menu() {
106+
public async Task Menu_Invoke_ReturnsNavigationViewModel() {
107107

108108
var viewComponent = new MenuViewComponent(_topicRepository, _hierarchicalMappingService) {
109109
ViewComponentContext = _context
@@ -122,13 +122,13 @@ public async Task Menu() {
122122
}
123123

124124
/*==========================================================================================================================
125-
| TEST: PAGE-LEVEL NAVIGATION
125+
| TEST: PAGE-LEVEL NAVIGATION: INVOKE: RETURNS NAVIGATION VIEW MODEL
126126
\-------------------------------------------------------------------------------------------------------------------------*/
127127
/// <summary>
128128
/// Loads a new <see cref="PageLevelNavigationViewComponent"/> and confirms the resulting values.
129129
/// </summary>
130130
[TestMethod]
131-
public async Task PageLevelNavigation() {
131+
public async Task PageLevelNavigation_Invoke_ReturnsNavigationViewModel() {
132132

133133
var viewComponent = new PageLevelNavigationViewComponent(_topicRepository, _hierarchicalMappingService) {
134134
ViewComponentContext = _context

OnTopic.AspNetCore.Mvc.Tests/ValidateTopicAttributeTest.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -87,15 +87,15 @@ public static TopicController GetTopicController(Topic topic) =>
8787
};
8888

8989
/*==========================================================================================================================
90-
| TEST: INVALID CONTROLLER THROWS EXCEPTION
90+
| TEST: INVALID CONTROLLER TYPE THROWS EXCEPTION
9191
\-------------------------------------------------------------------------------------------------------------------------*/
9292
/// <summary>
9393
/// Ensures that a controller that doesn't derive from <see cref="TopicController"/> throws a <see
9494
/// cref="InvalidOperationException"/>.
9595
/// </summary>
9696
[TestMethod]
9797
[ExpectedException(typeof(InvalidOperationException))]
98-
public void InvalidController_Throws_Exception() {
98+
public void InvalidControllerType_ThrowsException() {
9999

100100
var validateFilter = new ValidateTopicAttribute();
101101
var controller = new DummyController() {
@@ -112,13 +112,13 @@ public void InvalidController_Throws_Exception() {
112112

113113
}
114114
/*==========================================================================================================================
115-
| TEST: NULL TOPIC RETURNS NOT FOUND
115+
| TEST: NULL TOPIC: RETURNS NOT FOUND
116116
\-------------------------------------------------------------------------------------------------------------------------*/
117117
/// <summary>
118118
/// Ensures that a <see cref="NotFoundObjectResult"/> is thrown if the <see cref="TopicController.CurrentTopic"/> is null.
119119
/// </summary>
120120
[TestMethod]
121-
public void NullTopic_Returns_NotFound() {
121+
public void NullTopic_ReturnsNotFound() {
122122

123123
var validateFilter = new ValidateTopicAttribute();
124124
var controller = GetTopicController(null);
@@ -133,13 +133,13 @@ public void NullTopic_Returns_NotFound() {
133133
}
134134

135135
/*==========================================================================================================================
136-
| TEST: DISABLED TOPIC RETURNS NOT AUTHORIZED
136+
| TEST: DISABLED TOPIC: RETURNS NOT AUTHORIZED
137137
\-------------------------------------------------------------------------------------------------------------------------*/
138138
/// <summary>
139139
/// Ensures that a <see cref="NotFoundObjectResult"/> is thrown if the <see cref="TopicController.CurrentTopic"/> is null.
140140
/// </summary>
141141
[TestMethod]
142-
public void DisabledTopic_Returns_NotFound() {
142+
public void DisabledTopic_ReturnsNotFound() {
143143

144144
var validateFilter = new ValidateTopicAttribute();
145145
var topic = TopicFactory.Create("Key", "Page");
@@ -157,14 +157,14 @@ public void DisabledTopic_Returns_NotFound() {
157157
}
158158

159159
/*==========================================================================================================================
160-
| TEST: TOPIC WITH URL RETURNS REDIRECT
160+
| TEST: TOPIC WITH URL: RETURNS REDIRECT
161161
\-------------------------------------------------------------------------------------------------------------------------*/
162162
/// <summary>
163163
/// Ensures that a <see cref="RedirectResult"/> is thrown if the <see cref="TopicController.CurrentTopic"/> contains
164164
/// a <c>Url</c> attribute.
165165
/// </summary>
166166
[TestMethod]
167-
public void TopicWithUrl_Returns_Redirect() {
167+
public void TopicWithUrl_ReturnsRedirect() {
168168

169169
var validateFilter = new ValidateTopicAttribute();
170170
var topic = TopicFactory.Create("Key", "Page");
@@ -182,14 +182,14 @@ public void TopicWithUrl_Returns_Redirect() {
182182
}
183183

184184
/*==========================================================================================================================
185-
| TEST: NESTED TOPIC RETURNS 403
185+
| TEST: NESTED TOPIC: RETURNS 403
186186
\-------------------------------------------------------------------------------------------------------------------------*/
187187
/// <summary>
188188
/// Ensures that a <see cref="StatusCodeResult"/> is thrown if the <see cref="TopicController.CurrentTopic"/> has a
189189
/// <see cref="ContentTypeDescriptor"/> of <c>List</c>.
190190
/// </summary>
191191
[TestMethod]
192-
public void NestedTopic_Returns_403() {
192+
public void NestedTopic_Returns403() {
193193

194194
var validateFilter = new ValidateTopicAttribute();
195195
var topic = TopicFactory.Create("Key", "List");
@@ -208,14 +208,14 @@ public void NestedTopic_Returns_403() {
208208
}
209209

210210
/*==========================================================================================================================
211-
| TEST: PAGE GROUP TOPIC RETURNS REDIRECT
211+
| TEST: PAGE GROUP TOPIC: RETURNS REDIRECT
212212
\-------------------------------------------------------------------------------------------------------------------------*/
213213
/// <summary>
214214
/// Ensures that a <see cref="RedirectResult"/> is thrown if the <see cref="TopicController.CurrentTopic"/> has a
215215
/// <see cref="ContentTypeDescriptor"/> of <c>PageGroup</c>.
216216
/// </summary>
217217
[TestMethod]
218-
public void PageGroupTopic_Returns_Redirect() {
218+
public void PageGroupTopic_ReturnsRedirect() {
219219

220220
var validateFilter = new ValidateTopicAttribute();
221221
var topic = TopicFactory.Create("Key", "PageGroup");

0 commit comments

Comments
 (0)