1
- using System . Diagnostics ;
2
1
using FluentAssertions . Execution ;
3
2
using FluentAssertions . Primitives ;
4
3
using Microsoft . AspNetCore . Mvc ;
4
+ using System . Diagnostics ;
5
5
6
6
namespace FluentAssertions . AspNetCore . Mvc
7
7
{
@@ -11,24 +11,25 @@ namespace FluentAssertions.AspNetCore.Mvc
11
11
[ DebuggerNonUserCode ]
12
12
public class ActionResultAssertions : ObjectAssertions
13
13
{
14
- public struct Constants
15
- {
16
- public const string CommonFailMessage = "Expected ActionResult to be {0}{reason}, but found {1}" ;
17
- }
14
+ #region Public Constructors
18
15
19
16
/// <summary>
20
17
/// Initializes a new instance of the <see cref="T:ActionResultAssertions" /> class.
21
18
/// </summary>
22
- public ActionResultAssertions ( ActionResult subject ) : base ( subject )
19
+ public ActionResultAssertions ( ActionResult subject ) : base ( subject )
23
20
{
24
21
Subject = subject ;
25
22
}
26
23
27
- public ActionResultAssertions ( IActionResult subject ) : base ( subject )
24
+ public ActionResultAssertions ( IActionResult subject ) : base ( subject )
28
25
{
29
26
Subject = subject ;
30
27
}
31
28
29
+ #endregion Public Constructors
30
+
31
+ #region Public Methods
32
+
32
33
/// <summary>
33
34
/// Asserts that the subject is a <see cref="ContentResult"/>.
34
35
/// </summary>
@@ -41,7 +42,7 @@ public ContentResultAssertions BeContentResult()
41
42
/// Asserts that the subject is a <see cref="ContentResult"/>.
42
43
/// </summary>
43
44
/// <param name="reason">
44
- /// A formatted phrase as is supported by <see cref="string.Format(string,object[])" /> explaining why the assertion
45
+ /// A formatted phrase as is supported by <see cref="string.Format(string,object[])" /> explaining why the assertion
45
46
/// is needed. If the phrase does not start with the word <i>because</i>, it is prepended automatically.
46
47
/// </param>
47
48
/// <param name="reasonArgs">
@@ -69,7 +70,7 @@ public EmptyResult BeEmptyResult()
69
70
/// Asserts that the subject is an <see cref="EmptyResult"/>.
70
71
/// </summary>
71
72
/// <param name="reason">
72
- /// A formatted phrase as is supported by <see cref="string.Format(string,object[])" /> explaining why the assertion
73
+ /// A formatted phrase as is supported by <see cref="string.Format(string,object[])" /> explaining why the assertion
73
74
/// is needed. If the phrase does not start with the word <i>because</i>, it is prepended automatically.
74
75
/// </param>
75
76
/// <param name="reasonArgs">
@@ -88,6 +89,7 @@ public EmptyResult BeEmptyResult(string reason, params object[] reasonArgs)
88
89
/// <summary>
89
90
/// Asserts that the subject is a <see cref="RedirectToRouteResult"/>.
90
91
/// </summary>
92
+ [ CustomAssertion ]
91
93
public RedirectToRouteAssertions BeRedirectToRouteResult ( )
92
94
{
93
95
return BeRedirectToRouteResult ( string . Empty , null ) ;
@@ -97,12 +99,13 @@ public RedirectToRouteAssertions BeRedirectToRouteResult()
97
99
/// Asserts that the subject is a <see cref="RedirectToRouteResult"/>.
98
100
/// </summary>
99
101
/// <param name="reason">
100
- /// A formatted phrase as is supported by <see cref="string.Format(string,object[])" /> explaining why the assertion
102
+ /// A formatted phrase as is supported by <see cref="string.Format(string,object[])" /> explaining why the assertion
101
103
/// is needed. If the phrase does not start with the word <i>because</i>, it is prepended automatically.
102
104
/// </param>
103
105
/// <param name="reasonArgs">
104
106
/// Zero or more objects to format using the placeholders in <see cref="reason" />.
105
107
/// </param>
108
+ [ CustomAssertion ]
106
109
public RedirectToRouteAssertions BeRedirectToRouteResult ( string reason , params object [ ] reasonArgs )
107
110
{
108
111
Execute . Assertion
@@ -125,7 +128,7 @@ public PartialViewResultAssertions BePartialViewResult()
125
128
/// Asserts that the subject is a <see cref="PartialViewResult"/>.
126
129
/// </summary>
127
130
/// <param name="reason">
128
- /// A formatted phrase as is supported by <see cref="string.Format(string,object[])" /> explaining why the assertion
131
+ /// A formatted phrase as is supported by <see cref="string.Format(string,object[])" /> explaining why the assertion
129
132
/// is needed. If the phrase does not start with the word <i>because</i>, it is prepended automatically.
130
133
/// </param>
131
134
/// <param name="reasonArgs">
@@ -153,7 +156,7 @@ public RedirectResultAssertions BeRedirectResult()
153
156
/// Asserts that the subject is a <see cref="RedirectResult"/>.
154
157
/// </summary>
155
158
/// <param name="reason">
156
- /// A formatted phrase as is supported by <see cref="string.Format(string,object[])" /> explaining why the assertion
159
+ /// A formatted phrase as is supported by <see cref="string.Format(string,object[])" /> explaining why the assertion
157
160
/// is needed. If the phrase does not start with the word <i>because</i>, it is prepended automatically.
158
161
/// </param>
159
162
/// <param name="reasonArgs">
@@ -181,7 +184,7 @@ public ViewResultAssertions BeViewResult()
181
184
/// Asserts that the subject is a <see cref="ViewResult"/>.
182
185
/// </summary>
183
186
/// <param name="reason">
184
- /// A formatted phrase as is supported by <see cref="string.Format(string,object[])" /> explaining why the assertion
187
+ /// A formatted phrase as is supported by <see cref="string.Format(string,object[])" /> explaining why the assertion
185
188
/// is needed. If the phrase does not start with the word <i>because</i>, it is prepended automatically.
186
189
/// </param>
187
190
/// <param name="reasonArgs">
@@ -191,10 +194,25 @@ public ViewResultAssertions BeViewResult(string reason, params object[] reasonAr
191
194
{
192
195
Execute . Assertion
193
196
. BecauseOf ( reason , reasonArgs )
194
- . ForCondition ( Subject is ViewResult )
197
+ . ForCondition ( Subject is ViewResult )
195
198
. FailWith ( Constants . CommonFailMessage , "ViewResult" , Subject . GetType ( ) . Name ) ;
196
-
197
- return new ViewResultAssertions ( Subject as ViewResult ) ;
199
+
200
+ return new ViewResultAssertions ( Subject as ViewResult ) ;
198
201
}
202
+
203
+ #endregion Public Methods
204
+
205
+ #region Public Structs
206
+
207
+ public struct Constants
208
+ {
209
+ #region Public Fields
210
+
211
+ public const string CommonFailMessage = "Expected ActionResult to be {0}{reason}, but found {1}" ;
212
+
213
+ #endregion Public Fields
214
+ }
215
+
216
+ #endregion Public Structs
199
217
}
200
218
}
0 commit comments