1- using System . Diagnostics ;
21using FluentAssertions . Execution ;
32using FluentAssertions . Primitives ;
43using Microsoft . AspNetCore . Mvc ;
4+ using System . Diagnostics ;
55
66namespace FluentAssertions . AspNetCore . Mvc
77{
@@ -11,24 +11,25 @@ namespace FluentAssertions.AspNetCore.Mvc
1111 [ DebuggerNonUserCode ]
1212 public class ActionResultAssertions : ObjectAssertions
1313 {
14- public struct Constants
15- {
16- public const string CommonFailMessage = "Expected ActionResult to be {0}{reason}, but found {1}" ;
17- }
14+ #region Public Constructors
1815
1916 /// <summary>
2017 /// Initializes a new instance of the <see cref="T:ActionResultAssertions" /> class.
2118 /// </summary>
22- public ActionResultAssertions ( ActionResult subject ) : base ( subject )
19+ public ActionResultAssertions ( ActionResult subject ) : base ( subject )
2320 {
2421 Subject = subject ;
2522 }
2623
27- public ActionResultAssertions ( IActionResult subject ) : base ( subject )
24+ public ActionResultAssertions ( IActionResult subject ) : base ( subject )
2825 {
2926 Subject = subject ;
3027 }
3128
29+ #endregion Public Constructors
30+
31+ #region Public Methods
32+
3233 /// <summary>
3334 /// Asserts that the subject is a <see cref="ContentResult"/>.
3435 /// </summary>
@@ -41,7 +42,7 @@ public ContentResultAssertions BeContentResult()
4142 /// Asserts that the subject is a <see cref="ContentResult"/>.
4243 /// </summary>
4344 /// <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
4546 /// is needed. If the phrase does not start with the word <i>because</i>, it is prepended automatically.
4647 /// </param>
4748 /// <param name="reasonArgs">
@@ -69,7 +70,7 @@ public EmptyResult BeEmptyResult()
6970 /// Asserts that the subject is an <see cref="EmptyResult"/>.
7071 /// </summary>
7172 /// <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
7374 /// is needed. If the phrase does not start with the word <i>because</i>, it is prepended automatically.
7475 /// </param>
7576 /// <param name="reasonArgs">
@@ -88,6 +89,7 @@ public EmptyResult BeEmptyResult(string reason, params object[] reasonArgs)
8889 /// <summary>
8990 /// Asserts that the subject is a <see cref="RedirectToRouteResult"/>.
9091 /// </summary>
92+ [ CustomAssertion ]
9193 public RedirectToRouteAssertions BeRedirectToRouteResult ( )
9294 {
9395 return BeRedirectToRouteResult ( string . Empty , null ) ;
@@ -97,12 +99,13 @@ public RedirectToRouteAssertions BeRedirectToRouteResult()
9799 /// Asserts that the subject is a <see cref="RedirectToRouteResult"/>.
98100 /// </summary>
99101 /// <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
101103 /// is needed. If the phrase does not start with the word <i>because</i>, it is prepended automatically.
102104 /// </param>
103105 /// <param name="reasonArgs">
104106 /// Zero or more objects to format using the placeholders in <see cref="reason" />.
105107 /// </param>
108+ [ CustomAssertion ]
106109 public RedirectToRouteAssertions BeRedirectToRouteResult ( string reason , params object [ ] reasonArgs )
107110 {
108111 Execute . Assertion
@@ -125,7 +128,7 @@ public PartialViewResultAssertions BePartialViewResult()
125128 /// Asserts that the subject is a <see cref="PartialViewResult"/>.
126129 /// </summary>
127130 /// <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
129132 /// is needed. If the phrase does not start with the word <i>because</i>, it is prepended automatically.
130133 /// </param>
131134 /// <param name="reasonArgs">
@@ -153,7 +156,7 @@ public RedirectResultAssertions BeRedirectResult()
153156 /// Asserts that the subject is a <see cref="RedirectResult"/>.
154157 /// </summary>
155158 /// <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
157160 /// is needed. If the phrase does not start with the word <i>because</i>, it is prepended automatically.
158161 /// </param>
159162 /// <param name="reasonArgs">
@@ -181,7 +184,7 @@ public ViewResultAssertions BeViewResult()
181184 /// Asserts that the subject is a <see cref="ViewResult"/>.
182185 /// </summary>
183186 /// <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
185188 /// is needed. If the phrase does not start with the word <i>because</i>, it is prepended automatically.
186189 /// </param>
187190 /// <param name="reasonArgs">
@@ -191,10 +194,25 @@ public ViewResultAssertions BeViewResult(string reason, params object[] reasonAr
191194 {
192195 Execute . Assertion
193196 . BecauseOf ( reason , reasonArgs )
194- . ForCondition ( Subject is ViewResult )
197+ . ForCondition ( Subject is ViewResult )
195198 . FailWith ( Constants . CommonFailMessage , "ViewResult" , Subject . GetType ( ) . Name ) ;
196-
197- return new ViewResultAssertions ( Subject as ViewResult ) ;
199+
200+ return new ViewResultAssertions ( Subject as ViewResult ) ;
198201 }
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
199217 }
200218}
0 commit comments