1
+ using System . Diagnostics ;
1
2
using FluentAssertions . Primitives ;
2
3
using FluentAssertions . Execution ;
3
- using System ;
4
- #if NETSTANDARD1_6
5
4
using Microsoft . AspNetCore . Mvc ;
6
- #else
7
- using System . Web . Mvc ;
8
- #endif
9
- using System . Diagnostics ;
10
5
11
6
namespace FluentAssertions . Mvc
12
7
{
13
8
/// <summary>
14
9
/// Contains a number of methods to assert that an <see cref="ActionResult"/> is in the expected state.
15
10
/// </summary>
16
11
[ DebuggerNonUserCode ]
17
- public class ActionResultAssertions : ObjectAssertions
18
- {
12
+ public class ActionResultAssertions : ObjectAssertions
13
+ {
19
14
public struct Constants
20
15
{
21
16
public const string CommonFailMessage = "Expected ActionResult to be {0}{reason}, but found {1}" ;
@@ -24,17 +19,15 @@ public struct Constants
24
19
/// <summary>
25
20
/// Initializes a new instance of the <see cref="T:ActionResultAssertions" /> class.
26
21
/// </summary>
27
- public ActionResultAssertions ( ActionResult subject ) : base ( subject )
28
- {
29
- Subject = subject ;
30
- }
22
+ public ActionResultAssertions ( ActionResult subject ) : base ( subject )
23
+ {
24
+ Subject = subject ;
25
+ }
31
26
32
- #if NETSTANDARD1_6
33
27
public ActionResultAssertions ( IActionResult subject ) : base ( subject )
34
28
{
35
29
Subject = subject ;
36
30
}
37
- #endif
38
31
39
32
/// <summary>
40
33
/// Asserts that the subject is a <see cref="ContentResult"/>.
@@ -57,9 +50,9 @@ public ContentResultAssertions BeContentResult()
57
50
public ContentResultAssertions BeContentResult ( string reason , params object [ ] reasonArgs )
58
51
{
59
52
Execute . Assertion
60
- . BecauseOf ( reason , reasonArgs )
61
- . ForCondition ( Subject is ContentResult )
62
- . FailWith ( Constants . CommonFailMessage , typeof ( ContentResult ) . Name , Subject . GetType ( ) . Name ) ;
53
+ . BecauseOf ( reason , reasonArgs )
54
+ . ForCondition ( Subject is ContentResult )
55
+ . FailWith ( Constants . CommonFailMessage , typeof ( ContentResult ) . Name , Subject . GetType ( ) . Name ) ;
63
56
64
57
return new ContentResultAssertions ( Subject as ContentResult ) ;
65
58
}
@@ -85,9 +78,9 @@ public EmptyResult BeEmptyResult()
85
78
public EmptyResult BeEmptyResult ( string reason , params object [ ] reasonArgs )
86
79
{
87
80
Execute . Assertion
88
- . BecauseOf ( reason , reasonArgs )
89
- . ForCondition ( Subject is EmptyResult )
90
- . FailWith ( Constants . CommonFailMessage , typeof ( EmptyResult ) . Name , Subject . GetType ( ) . Name ) ;
81
+ . BecauseOf ( reason , reasonArgs )
82
+ . ForCondition ( Subject is EmptyResult )
83
+ . FailWith ( Constants . CommonFailMessage , typeof ( EmptyResult ) . Name , Subject . GetType ( ) . Name ) ;
91
84
92
85
return Subject as EmptyResult ;
93
86
}
@@ -113,9 +106,9 @@ public RedirectToRouteAssertions BeRedirectToRouteResult()
113
106
public RedirectToRouteAssertions BeRedirectToRouteResult ( string reason , params object [ ] reasonArgs )
114
107
{
115
108
Execute . Assertion
116
- . BecauseOf ( reason , reasonArgs )
117
- . ForCondition ( Subject is RedirectToRouteResult )
118
- . FailWith ( Constants . CommonFailMessage , typeof ( RedirectToRouteResult ) . Name , Subject . GetType ( ) . Name ) ;
109
+ . BecauseOf ( reason , reasonArgs )
110
+ . ForCondition ( Subject is RedirectToRouteResult )
111
+ . FailWith ( Constants . CommonFailMessage , typeof ( RedirectToRouteResult ) . Name , Subject . GetType ( ) . Name ) ;
119
112
120
113
return new RedirectToRouteAssertions ( Subject as RedirectToRouteResult ) ;
121
114
}
@@ -141,9 +134,9 @@ public PartialViewResultAssertions BePartialViewResult()
141
134
public PartialViewResultAssertions BePartialViewResult ( string reason , params object [ ] reasonArgs )
142
135
{
143
136
Execute . Assertion
144
- . BecauseOf ( reason , reasonArgs )
145
- . ForCondition ( Subject is PartialViewResult )
146
- . FailWith ( Constants . CommonFailMessage , typeof ( PartialViewResult ) . Name , Subject . GetType ( ) . Name ) ;
137
+ . BecauseOf ( reason , reasonArgs )
138
+ . ForCondition ( Subject is PartialViewResult )
139
+ . FailWith ( Constants . CommonFailMessage , typeof ( PartialViewResult ) . Name , Subject . GetType ( ) . Name ) ;
147
140
148
141
return new PartialViewResultAssertions ( Subject as PartialViewResult ) ;
149
142
}
@@ -169,9 +162,9 @@ public RedirectResultAssertions BeRedirectResult()
169
162
public RedirectResultAssertions BeRedirectResult ( string reason , params object [ ] reasonArgs )
170
163
{
171
164
Execute . Assertion
172
- . BecauseOf ( reason , reasonArgs )
173
- . ForCondition ( Subject is RedirectResult )
174
- . FailWith ( Constants . CommonFailMessage , "RedirectResult" , Subject . GetType ( ) . Name ) ;
165
+ . BecauseOf ( reason , reasonArgs )
166
+ . ForCondition ( Subject is RedirectResult )
167
+ . FailWith ( Constants . CommonFailMessage , "RedirectResult" , Subject . GetType ( ) . Name ) ;
175
168
176
169
return new RedirectResultAssertions ( Subject as RedirectResult ) ;
177
170
}
@@ -195,13 +188,13 @@ public ViewResultAssertions BeViewResult()
195
188
/// Zero or more objects to format using the placeholders in <see cref="reason" />.
196
189
/// </param>
197
190
public ViewResultAssertions BeViewResult ( string reason , params object [ ] reasonArgs )
198
- {
199
- Execute . Assertion
200
- . BecauseOf ( reason , reasonArgs )
201
- . ForCondition ( Subject is ViewResult )
202
- . FailWith ( Constants . CommonFailMessage , "ViewResult" , Subject . GetType ( ) . Name ) ;
191
+ {
192
+ Execute . Assertion
193
+ . BecauseOf ( reason , reasonArgs )
194
+ . ForCondition ( Subject is ViewResult )
195
+ . FailWith ( Constants . CommonFailMessage , "ViewResult" , Subject . GetType ( ) . Name ) ;
203
196
204
- return new ViewResultAssertions ( Subject as ViewResult ) ;
205
- }
206
- }
207
- }
197
+ return new ViewResultAssertions ( Subject as ViewResult ) ;
198
+ }
199
+ }
200
+ }
0 commit comments