99
1010namespace FluentAssertions . Mvc
1111{
12+ /// <summary>
13+ /// Contains a number of methods to assert that a <see cref="ViewResultBase"/> is in the expected state.
14+ /// </summary>
1215 [ DebuggerNonUserCode ]
1316 public abstract class ViewResultBaseAssertions < T > : ObjectAssertions
1417 where T : ViewResultBase
1518 {
19+ /// <summary>
20+ /// Initializes a new instance of the <see cref="T:ViewResultBaseAssertions" /> class.
21+ /// </summary>
1622 public ViewResultBaseAssertions ( ViewResultBase subject ) : base ( subject )
1723 {
1824 Subject = ( T ) subject ;
1925 }
2026
21- public ViewResultBaseAssertions < T > WithViewName ( string expectedViewName )
22- {
23- WithViewName ( expectedViewName , string . Empty , null ) ;
24- return this ;
25- }
26-
27- public ViewResultBaseAssertions < T > WithViewName ( string expectedViewName , string reason , params object [ ] reasonArgs )
27+ /// <summary>
28+ /// Asserts that the view name is the expected view name.
29+ /// </summary>
30+ /// <param name="expectedViewName">The view name.</param>
31+ /// <param name="reason">
32+ /// A formatted phrase as is supported by <see cref="string.Format(string,object[])" /> explaining why the assertion
33+ /// is needed. If the phrase does not start with the word <i>because</i>, it is prepended automatically.
34+ /// </param>
35+ /// <param name="reasonArgs">
36+ /// Zero or more objects to format using the placeholders in <see cref="reason" />.
37+ /// </param>
38+ public ViewResultBaseAssertions < T > WithViewName ( string expectedViewName , string reason = "" , params object [ ] reasonArgs )
2839 {
2940 string actualViewName = ( Subject as ViewResultBase ) . ViewName ;
3041
@@ -35,13 +46,19 @@ public ViewResultBaseAssertions<T> WithViewName(string expectedViewName, string
3546 return this ;
3647 }
3748
38- public ViewResultBaseAssertions < T > WithViewData ( string key , object expectedValue )
39- {
40- WithViewData ( key , expectedValue , string . Empty , null ) ;
41- return this ;
42- }
43-
44- public ViewResultBaseAssertions < T > WithViewData ( string key , object expectedValue , string reason , params object [ ] reasonArgs )
49+ /// <summary>
50+ /// Asserts that the view data contains the expected data.
51+ /// </summary>
52+ /// <param name="key">The expected view data key.</param>
53+ /// <param name="expectedValue">The expected view data.</param>
54+ /// <param name="reason">
55+ /// A formatted phrase as is supported by <see cref="string.Format(string,object[])" /> explaining why the assertion
56+ /// is needed. If the phrase does not start with the word <i>because</i>, it is prepended automatically.
57+ /// </param>
58+ /// <param name="reasonArgs">
59+ /// Zero or more objects to format using the placeholders in <see cref="reason" />.
60+ /// </param>
61+ public ViewResultBaseAssertions < T > WithViewData ( string key , object expectedValue , string reason = "" , params object [ ] reasonArgs )
4562 {
4663 ViewDataDictionary actualViewData = ( Subject as ViewResultBase ) . ViewData ;
4764
@@ -60,13 +77,19 @@ public ViewResultBaseAssertions<T> WithViewData(string key, object expectedValue
6077 return this ;
6178 }
6279
63- public ViewResultBaseAssertions < T > WithTempData ( string key , object expectedValue )
64- {
65- WithTempData ( key , expectedValue , string . Empty , null ) ;
66- return this ;
67- }
68-
69- public ViewResultBaseAssertions < T > WithTempData ( string key , object expectedValue , string reason , params object [ ] reasonArgs )
80+ /// <summary>
81+ /// Asserts that the temp data contains the expected data.
82+ /// </summary>
83+ /// <param name="key">The expected temp data key.</param>
84+ /// <param name="expectedValue">The expected temp data.</param>
85+ /// <param name="reason">
86+ /// A formatted phrase as is supported by <see cref="string.Format(string,object[])" /> explaining why the assertion
87+ /// is needed. If the phrase does not start with the word <i>because</i>, it is prepended automatically.
88+ /// </param>
89+ /// <param name="reasonArgs">
90+ /// Zero or more objects to format using the placeholders in <see cref="reason" />.
91+ /// </param>
92+ public ViewResultBaseAssertions < T > WithTempData ( string key , object expectedValue , string reason = "" , params object [ ] reasonArgs )
7093 {
7194 TempDataDictionary actualTempData = ( Subject as ViewResultBase ) . TempData ;
7295
@@ -80,6 +103,10 @@ public ViewResultBaseAssertions<T> WithTempData(string key, object expectedValue
80103 return this ;
81104 }
82105
106+
107+ /// <summary>
108+ /// The model.
109+ /// </summary>
83110 public object Model
84111 {
85112 get
@@ -89,6 +116,11 @@ public object Model
89116 }
90117 }
91118
119+ /// <summary>
120+ /// Asserts the model is of the expected type.
121+ /// </summary>
122+ /// <typeparam name="TModel">The expected type.</typeparam>
123+ /// <returns>The typed model.</returns>
92124 public TModel ModelAs < TModel > ( )
93125 {
94126 object model = ( Subject as ViewResultBase ) . Model ;
@@ -103,13 +135,17 @@ public TModel ModelAs<TModel>()
103135 return ( TModel ) model ;
104136 }
105137
106- public ViewResultBaseAssertions < T > WithDefaultViewName ( )
107- {
108- WithDefaultViewName ( string . Empty , null ) ;
109- return this ;
110- }
111-
112- public ViewResultBaseAssertions < T > WithDefaultViewName ( string reason , params object [ ] reasonArgs )
138+ /// <summary>
139+ /// Asserts that the default view will be used.
140+ /// </summary>
141+ /// <param name="reason">
142+ /// A formatted phrase as is supported by <see cref="string.Format(string,object[])" /> explaining why the assertion
143+ /// is needed. If the phrase does not start with the word <i>because</i>, it is prepended automatically.
144+ /// </param>
145+ /// <param name="reasonArgs">
146+ /// Zero or more objects to format using the placeholders in <see cref="reason" />.
147+ /// </param>
148+ public ViewResultBaseAssertions < T > WithDefaultViewName ( string reason = "" , params object [ ] reasonArgs )
113149 {
114150 string viewName = ( Subject as ViewResultBase ) . ViewName ;
115151
0 commit comments