Skip to content

Commit 6d395a4

Browse files
committed
Added ShouldReturn/ShouldReturnActionResult (#359)
1 parent a403a7f commit 6d395a4

4 files changed

Lines changed: 40 additions & 22 deletions

File tree

src/MyTested.AspNetCore.Mvc.Controllers/Builders/Actions/ShouldReturn/ShouldReturnActionResult.cs

Lines changed: 0 additions & 6 deletions
This file was deleted.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
namespace MyTested.AspNetCore.Mvc.Builders.Actions.ShouldReturn
2+
{
3+
using Contracts.Actions;
4+
using Contracts.And;
5+
using Internal.TestContexts;
6+
7+
/// <summary>
8+
/// Used for testing returned <see cref="Microsoft.AspNetCore.Mvc.ActionResult"/>.
9+
/// </summary>
10+
/// <typeparam name="TActionResult">Result from invoked action in ASP.NET Core MVC controller.</typeparam>
11+
public class ShouldReturnActionResultTestBuilder<TActionResult>
12+
: ShouldReturnTestBuilder<TActionResult>, IShouldReturnActionResultTestBuilder<TActionResult>
13+
{
14+
/// <summary>
15+
/// Initializes a new instance of the <see cref="ShouldReturnActionResultTestBuilder{TActionResult}"/> class.
16+
/// </summary>
17+
/// <param name="testContext"><see cref="ControllerTestContext"/> containing data about the currently executed assertion chain.</param>
18+
public ShouldReturnActionResultTestBuilder(ControllerTestContext testContext)
19+
: base(testContext)
20+
{
21+
}
22+
23+
/// <inheritdoc />
24+
public new IAndTestBuilder ActionResult()
25+
{
26+
var result = base.ActionResult;
27+
throw new System.NotImplementedException();
28+
}
29+
}
30+
}

src/MyTested.AspNetCore.Mvc.Controllers/Builders/Contracts/Actions/IShouldReturnActionResultTestBuilder.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,19 @@
33
using System;
44
using And;
55

6+
/// <summary>
7+
/// Used for testing returned <see cref="Microsoft.AspNetCore.Mvc.ActionResult"/>.
8+
/// </summary>
9+
/// <typeparam name="TActionResult">Result from invoked action in ASP.NET Core MVC controller.</typeparam>
610
public interface IShouldReturnActionResultTestBuilder<TActionResult>
711
: IShouldReturnTestBuilder<TActionResult>
812
{
9-
// IActionResult, ActionResult or ActionResult<T>
13+
/// <summary>
14+
/// Tests whether the action result is <see cref="Microsoft.AspNetCore.Mvc.IActionResult"/>,
15+
/// <see cref="Microsoft.AspNetCore.Mvc.ActionResult"/> or
16+
/// <see cref="Microsoft.AspNetCore.Mvc.ActionResult{TResult}"/>.
17+
/// </summary>
18+
/// <returns>Test builder of <see cref="IAndTestBuilder"/> type.</returns>
1019
IAndTestBuilder ActionResult();
1120

1221
//// IActionResult, ActionResult or ActionResult<T> with options to specify the result - Ok() for example

src/MyTested.AspNetCore.Mvc.Controllers/Builders/Contracts/Actions/IShouldReturnTestBuilder.cs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,6 @@
2626
public interface IShouldReturnTestBuilder<TActionResult>
2727
: IBaseShouldReturnTestBuilder<TActionResult, IAndTestBuilder>
2828
{
29-
// IActionResult, ActionResult or ActionResult<T>
30-
IAndTestBuilder ActionResult();
31-
32-
// IActionResult, ActionResult or ActionResult<T> with options to specify the result - Ok() for example
33-
IAndTestBuilder ActionResult(Action<IShouldReturnTestBuilder<TActionResult>> actionResultTestBuilder);
34-
35-
//// ActionResult<TResult>, consider OkResult for example to be valid too?
36-
//IAndTestBuilder ActionResult<TResult>();
37-
38-
//// ActionResult<TResult>, consider OkResult for example to be valid too? with additional options to specify the result - Ok() for example
39-
//IAndTestBuilder ActionResult<TResult>(Action<IShouldReturnTestBuilder<TActionResult>> actionResultTestBuilder);
40-
41-
//// ActionResult<TResult>, consider OkResult for example to be valid too?!, with additional options to validate the TResult, like EqualTo or Passing (model/result details)
42-
//IAndTestBuilder ActionResult<TResult>(Action<IShouldHaveTestBuilder<TActionResult>> actionResultTestBuilder);
43-
4429
/// <summary>
4530
/// Tests whether the action result is <see cref="Microsoft.AspNetCore.Mvc.AcceptedResult"/>,
4631
/// <see cref="Microsoft.AspNetCore.Mvc.AcceptedAtActionResult"/> or

0 commit comments

Comments
 (0)