Skip to content

Commit a480aba

Browse files
committed
Added documentation summary on action test builder
1 parent 07294e3 commit a480aba

File tree

8 files changed

+216
-126
lines changed

8 files changed

+216
-126
lines changed

src/MyTested.Mvc/Builders/Actions/ShouldHave/ShouldHaveViewBag.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ public IAndTestBuilder<TActionResult> ViewBag(int? withNumberOfEntries = null)
3434
}
3535

3636
/// <inheritdoc />
37-
public IAndTestBuilder<TActionResult> ViewBag(Action<IViewBagTestBuilder> viewDataTestBuilder)
37+
public IAndTestBuilder<TActionResult> ViewBag(Action<IViewBagTestBuilder> viewBagTestBuilder)
3838
{
39-
viewDataTestBuilder(new ViewBagTestBuilder(this.TestContext));
39+
viewBagTestBuilder(new ViewBagTestBuilder(this.TestContext));
4040
return this.NewAndTestBuilder();
4141
}
4242
}

src/MyTested.Mvc/Builders/Contracts/Actions/IActionResultTestBuilder.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,27 @@
33
using Base;
44

55
/// <summary>
6-
/// Used for building the action result which will be tested.
6+
/// Used for testing the action and its result.
77
/// </summary>
88
/// <typeparam name="TActionResult">Type of action result to be tested.</typeparam>
99
public interface IActionResultTestBuilder<TActionResult> : IBaseTestBuilderWithActionResult<TActionResult>
1010
{
1111
/// <summary>
12-
/// Used for testing action attributes and model state.
12+
/// Used for testing the action's additional data - action attributes, HTTP response, view bag and more.
1313
/// </summary>
14-
/// <returns>Should have test builder.</returns>
14+
/// <returns>Test builder of <see cref="IShouldHaveTestBuilder{TActionResult}"/> type.</returns>
1515
IShouldHaveTestBuilder<TActionResult> ShouldHave();
1616

1717
/// <summary>
18-
/// Used for testing whether action throws exception.
18+
/// Used for testing whether the action throws exception.
1919
/// </summary>
20-
/// <returns>Should throw test builder.</returns>
20+
/// <returns>Test builder of <see cref="IShouldThrowTestBuilder"/>.</returns>
2121
IShouldThrowTestBuilder ShouldThrow();
2222

2323
/// <summary>
2424
/// Used for testing returned action result.
2525
/// </summary>
26-
/// <returns>Should return test builder.</returns>
26+
/// <returns>Test builder of <see cref="IShouldReturnTestBuilder<TActionResult>"/>.</returns>
2727
IShouldReturnTestBuilder<TActionResult> ShouldReturn();
2828
}
2929
}

src/MyTested.Mvc/Builders/Contracts/Actions/IShouldHaveTestBuilder.cs

Lines changed: 97 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,85 +9,163 @@
99
using Models;
1010

1111
/// <summary>
12-
/// Used for testing action attributes and model state.
12+
/// Used for testing the action's additional data - action attributes, HTTP response, view bag and more.
1313
/// </summary>
1414
/// <typeparam name="TActionResult">Result from invoked action in ASP.NET Core MVC controller.</typeparam>
1515
public interface IShouldHaveTestBuilder<TActionResult> : IBaseTestBuilderWithActionResult<TActionResult>
1616
{
1717
/// <summary>
18-
/// Checks whether the tested action has no attributes of any type.
18+
/// Tests whether the action has no attributes of any type.
1919
/// </summary>
20-
/// <returns>Test builder with AndAlso method.</returns>
20+
/// <returns>Test builder of <see cref="IAndTestBuilder<TActionResult>"/> type.</returns>
2121
IAndTestBuilder<TActionResult> NoActionAttributes();
2222

2323
/// <summary>
24-
/// Checks whether the tested action has at least 1 attribute of any type.
24+
/// Tests whether the action has at least 1 attribute of any type.
2525
/// </summary>
2626
/// <param name="withTotalNumberOf">Optional parameter specifying the exact total number of attributes on the tested action.</param>
27-
/// <returns>Test builder with AndAlso method.</returns>
27+
/// <returns>Test builder of <see cref="IAndTestBuilder<TActionResult>"/> type.</returns>
2828
IAndTestBuilder<TActionResult> ActionAttributes(int? withTotalNumberOf = null);
2929

3030
/// <summary>
31-
/// Checks whether the tested action has at specific attributes.
31+
/// Tests whether the action has specific attributes.
3232
/// </summary>
3333
/// <param name="attributesTestBuilder">Builder for testing specific attributes on the action.</param>
34-
/// <returns>Test builder with AndAlso method.</returns>
34+
/// <returns>Test builder of <see cref="IAndTestBuilder<TActionResult>"/> type.</returns>
3535
IAndTestBuilder<TActionResult> ActionAttributes(Action<IActionAttributesTestBuilder> attributesTestBuilder);
3636

3737
/// <summary>
38-
/// Provides way to continue test case with specific model state errors.
38+
/// Tests whether the action has specific <see cref="Microsoft.AspNetCore.Mvc.ModelBinding.ModelStateDictionary"/> errors.
3939
/// </summary>
4040
/// <typeparam name="TRequestModel">Request model type to be tested for errors.</typeparam>
41-
/// <returns>Test builder with AndAlso method.</returns>
41+
/// <param name="modelErrorTestBuilder">Builder for testing specific <see cref="Microsoft.AspNetCore.Mvc.ModelBinding.ModelStateDictionary"/>
42+
/// errors for the provided model type.</param>
43+
/// <returns>Test builder of <see cref="IAndTestBuilder<TActionResult>"/> type.</returns>
4244
IAndTestBuilder<TActionResult> ModelStateFor<TRequestModel>(Action<IModelErrorTestBuilder<TRequestModel>> modelErrorTestBuilder);
4345

4446
/// <summary>
45-
/// Checks whether the tested action's provided model state is valid.
47+
/// Tests whether the action has valid <see cref="Microsoft.AspNetCore.Mvc.ModelBinding.ModelStateDictionary"/> with no errors.
4648
/// </summary>
47-
/// <returns>Test builder with AndAlso method.</returns>
49+
/// <returns>Test builder of <see cref="IAndTestBuilder<TActionResult>"/> type.</returns>
4850
IAndTestBuilder<TActionResult> ValidModelState();
4951

5052
/// <summary>
51-
/// Checks whether the tested action's provided model state is not valid.
53+
/// Tests whether the action has invalid <see cref="Microsoft.AspNetCore.Mvc.ModelBinding.ModelStateDictionary"/>.
5254
/// </summary>
53-
/// <param name="withNumberOfErrors">Expected number of errors. If default null is provided, the test builder checks only if any errors are found.</param>
54-
/// <returns>Test builder with AndAlso method.</returns>
55+
/// <param name="withNumberOfErrors">Expected number of <see cref="Microsoft.AspNetCore.Mvc.ModelBinding.ModelStateDictionary"/> errors.
56+
/// If default null is provided, the test builder checks only if any errors are found.</param>
57+
/// <returns>Test builder of <see cref="IAndTestBuilder<TActionResult>"/> type.</returns>
5558
IAndTestBuilder<TActionResult> InvalidModelState(int? withNumberOfErrors = null);
56-
59+
60+
/// <summary>
61+
/// Tests whether the action sets entries in the <see cref="Microsoft.Extensions.Caching.Memory.IMemoryCache"/>.
62+
/// </summary>
63+
/// <param name="withNumberOfEntries">Expected number of <see cref="Microsoft.Extensions.Caching.Memory.IMemoryCache"/> entries.
64+
/// If default null is provided, the test builder checks only if any entries are found.</param>
65+
/// <returns>Test builder of <see cref="IAndTestBuilder<TActionResult>"/> type.</returns>
5766
IAndTestBuilder<TActionResult> MemoryCache(int? withNumberOfEntries = null);
5867

68+
/// <summary>
69+
/// Tests whether the action sets specific <see cref="Microsoft.AspNetCore.Mvc.ModelBinding.ModelStateDictionary"/> entries.
70+
/// </summary>
71+
/// <param name="memoryCacheTestBuilder">Builder for testing specific <see cref="Microsoft.AspNetCore.Mvc.ModelBinding.ModelStateDictionary"/> entries.</param>
72+
/// <returns>Test builder of <see cref="IAndTestBuilder<TActionResult>"/> type.</returns>
5973
IAndTestBuilder<TActionResult> MemoryCache(Action<IMemoryCacheTestBuilder> memoryCacheTestBuilder);
6074

75+
/// <summary>
76+
/// Tests whether the action does not set any <see cref="Microsoft.AspNetCore.Mvc.ModelBinding.ModelStateDictionary"/> entries.
77+
/// </summary>
78+
/// <returns>Test builder of <see cref="IAndTestBuilder<TActionResult>"/> type.</returns>
6179
IAndTestBuilder<TActionResult> NoMemoryCache();
6280

81+
/// <summary>
82+
/// Tests whether the action sets entries in the <see cref="Microsoft.AspNetCore.Http.Features.ISession"/>.
83+
/// </summary>
84+
/// <param name="withNumberOfEntries">Expected number of <see cref="Microsoft.AspNetCore.Http.Features.ISession"/> entries.
85+
/// If default null is provided, the test builder checks only if any entries are found.</param>
86+
/// <returns>Test builder of <see cref="IAndTestBuilder<TActionResult>"/> type.</returns>
6387
IAndTestBuilder<TActionResult> Session(int? withNumberOfEntries = null);
6488

89+
/// <summary>
90+
/// Tests whether the action sets specific <see cref="Microsoft.AspNetCore.Http.Features.ISession"/> entries.
91+
/// </summary>
92+
/// <param name="sessionTestBuilder">Builder for testing specific <see cref="Microsoft.AspNetCore.Http.Features.ISession"/> entries.</param>
93+
/// <returns>Test builder of <see cref="IAndTestBuilder<TActionResult>"/> type.</returns>
6594
IAndTestBuilder<TActionResult> Session(Action<ISessionTestBuilder> sessionTestBuilder);
6695

96+
/// <summary>
97+
/// Tests whether the action does not set any <see cref="Microsoft.AspNetCore.Http.Features.ISession"/> entries.
98+
/// </summary>
99+
/// <returns>Test builder of <see cref="IAndTestBuilder<TActionResult>"/> type.</returns>
67100
IAndTestBuilder<TActionResult> NoSession();
68101

102+
/// <summary>
103+
/// Tests whether the action sets entries in the <see cref="Microsoft.AspNetCore.Mvc.ViewFeatures.ITempDataDictionary"/>.
104+
/// </summary>
105+
/// <param name="withNumberOfEntries">Expected number of <see cref="Microsoft.AspNetCore.Mvc.ViewFeatures.ITempDataDictionary"/> entries.
106+
/// If default null is provided, the test builder checks only if any entries are found.</param>
107+
/// <returns>Test builder of <see cref="IAndTestBuilder<TActionResult>"/> type.</returns>
69108
IAndTestBuilder<TActionResult> TempData(int? withNumberOfEntries = null);
70109

110+
/// <summary>
111+
/// Tests whether the action sets specific entries in the <see cref="Microsoft.AspNetCore.Mvc.ViewFeatures.ITempDataDictionary"/>.
112+
/// </summary>
113+
/// <param name="tempDataTestBuilder">Builder for testing specific <see cref="Microsoft.AspNetCore.Mvc.ViewFeatures.ITempDataDictionary"/> entries.</param>
114+
/// <returns>Test builder of <see cref="IAndTestBuilder<TActionResult>"/> type.</returns>
71115
IAndTestBuilder<TActionResult> TempData(Action<ITempDataTestBuilder> tempDataTestBuilder);
72116

117+
/// <summary>
118+
/// Tests whether the action does not set any <see cref="Microsoft.AspNetCore.Mvc.ViewFeatures.ITempDataDictionary"/> entries.
119+
/// </summary>
120+
/// <returns>Test builder of <see cref="IAndTestBuilder<TActionResult>"/> type.</returns>
73121
IAndTestBuilder<TActionResult> NoTempData();
74-
122+
123+
/// <summary>
124+
/// Tests whether the action sets entries in the <see cref="Microsoft.AspNetCore.Mvc.Controller.ViewBag"/>.
125+
/// </summary>
126+
/// <param name="withNumberOfEntries">Expected number of <see cref="Microsoft.AspNetCore.Mvc.Controller.ViewBag"/> entries.
127+
/// If default null is provided, the test builder checks only if any entries are found.</param>
128+
/// <returns>Test builder of <see cref="IAndTestBuilder<TActionResult>"/> type.</returns>
75129
IAndTestBuilder<TActionResult> ViewBag(int? withNumberOfEntries = null);
76130

77-
IAndTestBuilder<TActionResult> ViewBag(Action<IViewBagTestBuilder> viewDataTestBuilder);
131+
/// <summary>
132+
/// Tests whether the action sets specific entries in the <see cref="Microsoft.AspNetCore.Mvc.Controller.ViewBag"/>.
133+
/// </summary>
134+
/// <param name="viewBagTestBuilder">Builder for testing specific <see cref="Microsoft.AspNetCore.Mvc.Controller.ViewBag"/> entries.</param>
135+
/// <returns>Test builder of <see cref="IAndTestBuilder<TActionResult>"/> type.</returns>
136+
IAndTestBuilder<TActionResult> ViewBag(Action<IViewBagTestBuilder> viewBagTestBuilder);
78137

138+
/// <summary>
139+
/// Tests whether the action does not set any <see cref="Microsoft.AspNetCore.Mvc.Controller.ViewBag"/> entries.
140+
/// </summary>
141+
/// <returns>Test builder of <see cref="IAndTestBuilder<TActionResult>"/> type.</returns>
79142
IAndTestBuilder<TActionResult> NoViewBag();
80143

144+
/// <summary>
145+
/// Tests whether the action sets entries in the <see cref="Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary"/>.
146+
/// </summary>
147+
/// <param name="withNumberOfEntries">Expected number of <see cref="Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary"/> entries.
148+
/// If default null is provided, the test builder checks only if any entries are found.</param>
149+
/// <returns>Test builder of <see cref="IAndTestBuilder<TActionResult>"/> type.</returns>
81150
IAndTestBuilder<TActionResult> ViewData(int? withNumberOfEntries = null);
82151

152+
/// <summary>
153+
/// Tests whether the action sets specific entries in the <see cref="Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary"/>.
154+
/// </summary>
155+
/// <param name="viewBagTestBuilder">Builder for testing specific <see cref="Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary"/> entries.</param>
156+
/// <returns>Test builder of <see cref="IAndTestBuilder<TActionResult>"/> type.</returns>
83157
IAndTestBuilder<TActionResult> ViewData(Action<IViewDataTestBuilder> viewDataTestBuilder);
84158

159+
/// <summary>
160+
/// Tests whether the action does not set any <see cref="Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary"/> entries.
161+
/// </summary>
162+
/// <returns>Test builder of <see cref="IAndTestBuilder<TActionResult>"/> type.</returns>
85163
IAndTestBuilder<TActionResult> NoViewData();
86164

87165
/// <summary>
88-
/// Checks whether the tested action applies additional features to the HTTP response.
166+
/// Tests whether the action applies additional features to the HTTP response.
89167
/// </summary>
90-
/// <returns>Test builder with AndAlso method.</returns>
168+
/// <returns>Test builder of <see cref="IAndTestBuilder<TActionResult>"/> type.</returns>
91169
IAndTestBuilder<TActionResult> HttpResponse(Action<IHttpResponseTestBuilder> httpResponseTestBuilder);
92170
}
93171
}

0 commit comments

Comments
 (0)