Skip to content

Commit 76d3bc8

Browse files
committed
Cleared the strange API calls (closes #81)
1 parent e6d53d0 commit 76d3bc8

File tree

13 files changed

+22
-21
lines changed

13 files changed

+22
-21
lines changed

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,8 @@ MyMvc
189189
.ChangingActionNameTo("AnotherAction"));
190190

191191
// tests whether model state error exists by using lambda expression
192-
// and specific tests for the error messages
192+
// and with specific tests for the error messages
193+
// and tests whether the action return view with the same request model
193194
MyMvc
194195
.Controller<MvcController>()
195196
.Calling(c => c.MyAction(requestWithErrors))
@@ -198,7 +199,10 @@ MyMvc
198199
.ContainingNoErrorFor(m => m.NonRequiredProperty)
199200
.AndAlso()
200201
.ContainingErrorFor(m => m.RequiredProperty)
201-
.ThatEquals("The RequiredProperty field is required."));
202+
.ThatEquals("The RequiredProperty field is required."))
203+
.AndAlso()
204+
.ShouldReturn()
205+
.View(requestWithErrors);
202206

203207
// tests whether the action throws
204208
// with exception of certain type and with certain message

src/MyTested.AspNetCore.Mvc.Abstractions/Builders/Contracts/Base/IBaseTestBuilderWithComponentShouldHaveTestBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
namespace MyTested.AspNetCore.Mvc.Builders.Contracts.Base
22
{
3-
public interface IBaseTestBuilderWithComponentShouldHaveTestBuilder<TBuilder> : IBaseTestBuilderWithComponent
3+
public interface IBaseTestBuilderWithComponentShouldHaveTestBuilder<TBuilder> : IBaseTestBuilder
44
where TBuilder : IBaseTestBuilder
55
{
66
}

src/MyTested.AspNetCore.Mvc.Controllers/Builders/And/AndActionResultTestBuilder.cs renamed to src/MyTested.AspNetCore.Mvc.Controllers/Builders/Actions/AndActionResultTestBuilder.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
1-
namespace MyTested.AspNetCore.Mvc.Builders.And
1+
namespace MyTested.AspNetCore.Mvc.Builders.Actions
22
{
3-
using Actions;
4-
using Base;
3+
using ShouldHave;
54
using Contracts.Actions;
6-
using Contracts.And;
75
using Internal;
86
using Internal.TestContexts;
97

108
/// <summary>
119
/// Class containing AndAlso() method allowing additional assertions after action tests.
1210
/// </summary>
1311
/// <typeparam name="TActionResult">Result from invoked action in ASP.NET Core MVC controller.</typeparam>
14-
public class AndActionResultTestBuilder<TActionResult> : BaseTestBuilderWithActionResult<TActionResult>,
12+
public class AndActionResultTestBuilder<TActionResult> : ShouldHaveTestBuilder<TActionResult>,
1513
IAndActionResultTestBuilder<TActionResult>
1614
{
1715
/// <summary>

src/MyTested.AspNetCore.Mvc.Controllers/Builders/Actions/ShouldHave/ShouldHaveActionAttributes.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
{
33
using System;
44
using Attributes;
5-
using Contracts.And;
5+
using Contracts.Actions;
66
using Contracts.Attributes;
77
using Exceptions;
88
using Utilities.Extensions;

src/MyTested.AspNetCore.Mvc.Controllers/Builders/Actions/ShouldHave/ShouldHaveTestBuilder.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
namespace MyTested.AspNetCore.Mvc.Builders.Actions.ShouldHave
22
{
3-
using System;
4-
using And;
3+
using Actions;
54
using Base;
65
using Contracts.Actions;
7-
using Contracts.And;
86
using Internal.TestContexts;
97
using Utilities.Validators;
108

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
1-
namespace MyTested.AspNetCore.Mvc.Builders.Contracts.And
1+
namespace MyTested.AspNetCore.Mvc.Builders.Contracts.Actions
22
{
3-
using Actions;
4-
using Base;
5-
63
/// <summary>
74
/// Contains AndAlso() method allowing additional assertions after the action result tests.
85
/// </summary>
96
/// <typeparam name="TActionResult">Result from invoked action in ASP.NET Core MVC controller.</typeparam>
10-
public interface IAndActionResultTestBuilder<TActionResult> : IBaseTestBuilderWithActionResult<TActionResult>
7+
public interface IAndActionResultTestBuilder<TActionResult> : IShouldHaveTestBuilder<TActionResult>
118
{
129
/// <summary>
1310
/// Method allowing additional assertions after the action tests.

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
namespace MyTested.AspNetCore.Mvc.Builders.Contracts.Actions
22
{
33
using System;
4-
using And;
54
using Attributes;
65
using Base;
76

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
/// Used for testing returned action result.
2222
/// </summary>
2323
/// <typeparam name="TActionResult">Result from invoked action in ASP.NET Core MVC controller.</typeparam>
24-
public interface IShouldReturnTestBuilder<TActionResult> : IBaseTestBuilderWithActionResult<TActionResult>
24+
public interface IShouldReturnTestBuilder<TActionResult>
2525
{
2626
/// <summary>
2727
/// Tests whether the action result is the default value of the type.

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
namespace MyTested.AspNetCore.Mvc.Builders.Contracts.Actions
22
{
3-
using Base;
43
using ExceptionErrors;
54

65
/// <summary>
76
/// Used for testing whether the action throws exception.
87
/// </summary>
9-
public interface IShouldThrowTestBuilder : IBaseTestBuilderWithInvokedAction
8+
public interface IShouldThrowTestBuilder
109
{
1110
/// <summary>
1211
/// Tests whether the action throws any exception.

test/MyTested.AspNetCore.Mvc.Controllers.Test/BuildersTests/ActionResultsTests/OkTests/OkTestBuilderTests.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ public void WithResponseModelShouldWorkCorrectly()
4747
MyController<MvcController>
4848
.Instance()
4949
.Calling(c => c.OkResultWithResponse())
50+
.ShouldHave()
51+
.NoActionAttributes()
52+
.AndAlso()
5053
.ShouldReturn()
5154
.Ok()
5255
.WithModelOfType<List<ResponseModel>>();

0 commit comments

Comments
 (0)