Skip to content

Commit 5b47a7b

Browse files
committed
Added documentation on some of the action results
1 parent 0ec95bd commit 5b47a7b

21 files changed

+192
-192
lines changed

src/MyTested.Mvc/Builders/Base/BaseTestBuilderWithInvokedAction.cs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,34 @@
88
using ShouldPassFor;
99

1010
/// <summary>
11-
/// Base class for test builders with caught exception.
11+
/// Base class for test builders with invoked action.
1212
/// </summary>
1313
public abstract class BaseTestBuilderWithInvokedAction
1414
: BaseTestBuilderWithAction, IBaseTestBuilderWithInvokedAction
1515
{
1616
/// <summary>
1717
/// Initializes a new instance of the <see cref="BaseTestBuilderWithInvokedAction" /> class.
1818
/// </summary>
19-
/// <param name="controller">Controller on which the action will be tested.</param>
20-
/// <param name="actionName">Name of the tested action.</param>
21-
/// <param name="caughtException">Caught exception during the action execution.</param>
22-
/// <param name="actionAttributes">Collected action attributes from the method call.</param>
19+
/// <param name="testContext">Controller test context containing data about the currently executed assertion chain.</param>
2320
protected BaseTestBuilderWithInvokedAction(ControllerTestContext testContext)
2421
: base(testContext)
2522
{
2623
}
2724

25+
/// <summary>
26+
/// Gets the caught exception. Returns null, if such does not exist.
27+
/// </summary>
28+
/// <value>Result of type <see cref="Exception"/>.</value>
2829
internal Exception CaughtException => this.TestContext.CaughtException;
2930

31+
/// <inheritdoc />
3032
public new IShouldPassForTestBuilderWithInvokedAction ShouldPassFor()
3133
=> new ShouldPassForTestBuilderWithInvokedAction(this.TestContext);
3234

3335
/// <summary>
34-
/// Creates new AndProvideTestBuilder.
36+
/// Creates new <see cref="AndProvideTestBuilder"/>.
3537
/// </summary>
36-
/// <returns>Base test builder.</returns>
38+
/// <returns>Test builder of type <see cref="IBaseTestBuilderWithInvokedAction"/>.</returns>
3739
protected IBaseTestBuilderWithInvokedAction NewAndProvideTestBuilder()
3840
=> new AndProvideTestBuilder(this.TestContext);
3941
}

src/MyTested.Mvc/Builders/Base/BaseTestBuilderWithModel.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,13 @@ public abstract class BaseTestBuilderWithModel<TModel> : BaseTestBuilderWithInvo
1414
/// <summary>
1515
/// Initializes a new instance of the <see cref="BaseTestBuilderWithModel{TModel}" /> class.
1616
/// </summary>
17-
/// <param name="controller">Controller on which the action will be tested.</param>
18-
/// <param name="actionName">Name of the tested action.</param>
19-
/// <param name="caughtException">Caught exception during the action execution.</param>
20-
/// <param name="model">Model returned from action result.</param>
17+
/// <param name="testContext">Controller test context containing data about the currently executed assertion chain.</param>
2118
protected BaseTestBuilderWithModel(ControllerTestContext testContext)
2219
: base(testContext)
2320
{
2421
}
2522

23+
/// <inheritdoc />
2624
public new IShouldPassForTestBuilderWithModel<TModel> ShouldPassFor()
2725
{
2826
return new ShouldPassForTestBuilderWithModel<TModel>(this.TestContext);

src/MyTested.Mvc/Builders/Base/BaseTestBuilderWithResponseModel.cs

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
using Utilities.Validators;
1818

1919
/// <summary>
20-
/// Base class for all response model test builders.
20+
/// Base class for all test builders with response model.
2121
/// </summary>
2222
/// <typeparam name="TActionResult">Result from invoked action in ASP.NET Core MVC controller.</typeparam>
2323
public abstract class BaseTestBuilderWithResponseModel<TActionResult>
@@ -29,10 +29,7 @@ public abstract class BaseTestBuilderWithResponseModel<TActionResult>
2929
/// <summary>
3030
/// Initializes a new instance of the <see cref="BaseTestBuilderWithResponseModel{TActionResult}" /> class.
3131
/// </summary>
32-
/// <param name="controller">Controller on which the action will be tested.</param>
33-
/// <param name="actionName">Name of the tested action.</param>
34-
/// <param name="caughtException">Caught exception during the action execution.</param>
35-
/// <param name="actionResult">Result from the tested action.</param>
32+
/// <param name="testContext">Controller test context containing data about the currently executed assertion chain.</param>
3633
protected BaseTestBuilderWithResponseModel(ControllerTestContext testContext)
3734
: base(testContext)
3835
{
@@ -52,11 +49,7 @@ protected BaseTestBuilderWithResponseModel(ControllerTestContext testContext)
5249
/// <value>String value.</value>
5350
protected string OfTypeErrorMessageFormat { get; set; }
5451

55-
/// <summary>
56-
/// Tests whether certain type of response model is returned from the invoked action.
57-
/// </summary>
58-
/// <typeparam name="TResponseModel">Type of the response model.</typeparam>
59-
/// <returns>Builder for testing the response model errors.</returns>
52+
/// <inheritdoc />
6053
public IModelDetailsTestBuilder<TResponseModel> WithResponseModelOfType<TResponseModel>()
6154
{
6255
var actualResponseDataType = this.GetReturnType();
@@ -80,12 +73,7 @@ public IModelDetailsTestBuilder<TResponseModel> WithResponseModelOfType<TRespons
8073
return new ModelDetailsTestBuilder<TResponseModel>(this.TestContext);
8174
}
8275

83-
/// <summary>
84-
/// Tests whether a deeply equal object to the provided one is returned from the invoked action.
85-
/// </summary>
86-
/// <typeparam name="TResponseModel">Type of the response model.</typeparam>
87-
/// <param name="expectedModel">Expected model to be returned.</param>
88-
/// <returns>Builder for testing the response model errors.</returns>
76+
/// <inheritdoc />
8977
public IModelDetailsTestBuilder<TResponseModel> WithResponseModel<TResponseModel>(TResponseModel expectedModel)
9078
{
9179
this.WithResponseModelOfType<TResponseModel>();
@@ -107,7 +95,7 @@ public IModelDetailsTestBuilder<TResponseModel> WithResponseModel<TResponseModel
10795
/// <summary>
10896
/// Tests whether action result has the same status code as the provided one.
10997
/// </summary>
110-
/// <param name="statusCode">Status code.</param>
98+
/// <param name="statusCode">Status code as integer.</param>
11199
protected void ValidateStatusCode(int statusCode)
112100
{
113101
this.ValidateStatusCode((HttpStatusCode)statusCode);
@@ -116,7 +104,7 @@ protected void ValidateStatusCode(int statusCode)
116104
/// <summary>
117105
/// Tests whether action result has the same status code as the provided HttpStatusCode.
118106
/// </summary>
119-
/// <param name="statusCode">HttpStatusCode enumeration.</param>
107+
/// <param name="statusCode"><see cref="HttpStatusCode"/> enumeration.</param>
120108
protected void ValidateStatusCode(HttpStatusCode statusCode)
121109
{
122110
HttpStatusCodeValidator.ValidateHttpStatusCode(
@@ -137,7 +125,7 @@ protected void ValidateContainingOfContentType(string contentType)
137125
/// <summary>
138126
/// Tests whether action result contains the same content type as the provided MediaTypeHeaderValue.
139127
/// </summary>
140-
/// <param name="contentType">Expected content type as MediaTypeHeaderValue.</param>
128+
/// <param name="contentType">Expected content type as <see cref="MediaTypeHeaderValue"/>.</param>
141129
protected void ValidateContainingOfContentType(MediaTypeHeaderValue contentType)
142130
{
143131
ContentTypeValidator.ValidateContainingOfContentType(
@@ -167,7 +155,7 @@ protected void ValidateContentTypes(params string[] contentTypes)
167155
/// <summary>
168156
/// Tests whether action result contains the same content types as the provided ones.
169157
/// </summary>
170-
/// <param name="contentTypes">Expected content types as enumerable of MediaTypeHeaderValue.</param>
158+
/// <param name="contentTypes">Expected content types as enumerable of <see cref="MediaTypeHeaderValue"/>.</param>
171159
protected void ValidateContentTypes(IEnumerable<MediaTypeHeaderValue> contentTypes)
172160
{
173161
ContentTypeValidator.ValidateContentTypes(
@@ -179,7 +167,7 @@ protected void ValidateContentTypes(IEnumerable<MediaTypeHeaderValue> contentTyp
179167
/// <summary>
180168
/// Tests whether action result contains the same content types as the provided ones.
181169
/// </summary>
182-
/// <param name="contentTypes">Expected content types as MediaTypeHeaderValue parameters.</param>
170+
/// <param name="contentTypes">Expected content types as <see cref="MediaTypeHeaderValue"/> parameters.</param>
183171
protected void ValidateContentTypes(params MediaTypeHeaderValue[] contentTypes)
184172
{
185173
this.ValidateContentTypes(contentTypes.AsEnumerable());
@@ -188,7 +176,7 @@ protected void ValidateContentTypes(params MediaTypeHeaderValue[] contentTypes)
188176
/// <summary>
189177
/// Tests whether action result contains the same output formatter as the provided one.
190178
/// </summary>
191-
/// <param name="outputFormatter">Expected instance of IOutputFormatter.</param>
179+
/// <param name="outputFormatter">Expected instance of <see cref="IOutputFormatter"/>.</param>
192180
protected void ValidateContainingOfOutputFormatter(IOutputFormatter outputFormatter)
193181
{
194182
OutputFormatterValidator.ValidateContainingOfOutputFormatter(
@@ -200,7 +188,7 @@ protected void ValidateContainingOfOutputFormatter(IOutputFormatter outputFormat
200188
/// <summary>
201189
/// Tests whether action result contains type of output formatter as the provided one.
202190
/// </summary>
203-
/// <typeparam name="TOutputFormatter">Expected type of IOutputFormatter.</typeparam>
191+
/// <typeparam name="TOutputFormatter">Expected type of <see cref="IOutputFormatter"/>.</typeparam>
204192
protected void ValidateContainingOutputFormatterOfType<TOutputFormatter>()
205193
where TOutputFormatter : IOutputFormatter
206194
{
@@ -212,7 +200,7 @@ protected void ValidateContainingOutputFormatterOfType<TOutputFormatter>()
212200
/// <summary>
213201
/// Tests whether action result contains the same output formatters as the provided ones.
214202
/// </summary>
215-
/// <param name="outputFormatters">Expected enumerable of IOutputFormatter.</param>
203+
/// <param name="outputFormatters">Expected enumerable of <see cref="IOutputFormatter"/>.</param>
216204
protected void ValidateOutputFormatters(IEnumerable<IOutputFormatter> outputFormatters)
217205
{
218206
OutputFormatterValidator.ValidateOutputFormatters(
@@ -224,7 +212,7 @@ protected void ValidateOutputFormatters(IEnumerable<IOutputFormatter> outputForm
224212
/// <summary>
225213
/// Tests whether action result contains the same output formatters as the provided ones.
226214
/// </summary>
227-
/// <param name="outputFormatters">Expected IOutputFormatter parameters.</param>
215+
/// <param name="outputFormatters">Expected <see cref="IOutputFormatter"/> parameters.</param>
228216
protected void ValidateOutputFormatters(params IOutputFormatter[] outputFormatters)
229217
=> this.ValidateOutputFormatters(outputFormatters.AsEnumerable());
230218

src/MyTested.Mvc/Builders/Base/BaseTestBuilderWithViewFeature.cs

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
namespace MyTested.Mvc.Builders.Base
22
{
3-
using Builders.ShouldPassFor;
43
using Contracts.Base;
54
using Contracts.Models;
65
using Contracts.ShouldPassFor;
76
using Internal.TestContexts;
87
using Microsoft.AspNetCore.Mvc;
8+
using ShouldPassFor;
99

1010
/// <summary>
1111
/// Base class for all test builders with view features.
@@ -18,30 +18,19 @@ public abstract class BaseTestBuilderWithViewFeature<TViewResult>
1818
/// <summary>
1919
/// Initializes a new instance of the <see cref="BaseTestBuilderWithViewFeature{TActionResult}" /> class.
2020
/// </summary>
21-
/// <param name="controller">Controller on which the action will be tested.</param>
22-
/// <param name="actionName">Name of the tested action.</param>
23-
/// <param name="caughtException">Caught exception during the action execution.</param>
24-
/// <param name="viewResult">Result from the tested action.</param>
21+
/// <param name="testContext">Controller test context containing data about the currently executed assertion chain.</param>
2522
protected BaseTestBuilderWithViewFeature(ControllerTestContext testContext)
2623
: base(testContext)
2724
{
2825
}
2926

30-
/// <summary>
31-
/// Tests whether view result contains deeply equal model object as the provided one.
32-
/// </summary>
33-
/// <typeparam name="TModel">Type of model object.</typeparam>
34-
/// <param name="model">Model object.</param>
35-
/// <returns>Model details test builder.</returns>
27+
/// <inheritdoc />
3628
public IModelDetailsTestBuilder<TModel> WithModel<TModel>(TModel model) => this.WithResponseModel(model);
3729

38-
/// <summary>
39-
/// Tests whether view result contains model object of the provided type.
40-
/// </summary>
41-
/// <typeparam name="TModel">Type of model object.</typeparam>
42-
/// <returns>Model details test builder.</returns>
30+
/// <inheritdoc />
4331
public IModelDetailsTestBuilder<TModel> WithModelOfType<TModel>() => this.WithResponseModelOfType<TModel>();
44-
32+
33+
/// <inheritdoc />
4534
IShouldPassForTestBuilderWithActionResult<ActionResult> IBaseTestBuilderWithActionResult<ActionResult>.ShouldPassFor()
4635
=> new ShouldPassForTestBuilderWithActionResult<ActionResult>(this.TestContext);
4736
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
namespace MyTested.Mvc.Builders.Contracts.ActionResults.BadRequest
22
{
33
/// <summary>
4-
/// Used for adding AndAlso() method to the HTTP bad request response tests.
4+
/// Used for adding AndAlso() method to the HTTP bad request result tests.
55
/// </summary>
66
public interface IAndBadRequestTestBuilder : IBadRequestTestBuilder
77
{
88
/// <summary>
99
/// AndAlso method for better readability when chaining HTTP bad request result tests.
1010
/// </summary>
11-
/// <returns>HTTP bad request result test builder.</returns>
11+
/// <returns>The same <see cref="IBadRequestTestBuilder"/>.</returns>
1212
IBadRequestTestBuilder AndAlso();
1313
}
1414
}

src/MyTested.Mvc/Builders/Contracts/ActionResults/BadRequest/IBadRequestErrorMessageTestBuilder.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,28 @@ public interface IBadRequestErrorMessageTestBuilder : IBaseTestBuilderWithInvoke
1111
/// Tests whether particular error message is equal to given message.
1212
/// </summary>
1313
/// <param name="errorMessage">Expected error message for particular key.</param>
14-
/// <returns>HTTP bad request test builder.</returns>
14+
/// <returns>Test builder of type <see cref="IAndBadRequestTestBuilder"/>.</returns>
1515
IAndBadRequestTestBuilder ThatEquals(string errorMessage);
1616

1717
/// <summary>
1818
/// Tests whether particular error message begins with given message.
1919
/// </summary>
2020
/// <param name="beginMessage">Expected beginning for particular error message.</param>
21-
/// <returns>HTTP bad request test builder.</returns>
21+
/// <returns>Test builder of type <see cref="IAndBadRequestTestBuilder"/>.</returns>
2222
IAndBadRequestTestBuilder BeginningWith(string beginMessage);
2323

2424
/// <summary>
2525
/// Tests whether particular error message ends with given message.
2626
/// </summary>
2727
/// <param name="endMessage">Expected ending for particular error message.</param>
28-
/// <returns>HTTP bad request test builder.</returns>
28+
/// <returns>Test builder of type <see cref="IAndBadRequestTestBuilder"/>.</returns>
2929
IAndBadRequestTestBuilder EndingWith(string endMessage);
3030

3131
/// <summary>
3232
/// Tests whether particular error message contains given message.
3333
/// </summary>
3434
/// <param name="containsMessage">Expected containing string for particular error message.</param>
35-
/// <returns>HTTP bad request test builder.</returns>
35+
/// <returns>Test builder of type <see cref="IAndBadRequestTestBuilder"/>.</returns>
3636
IAndBadRequestTestBuilder Containing(string containsMessage);
3737
}
3838
}

0 commit comments

Comments
 (0)