9
9
10
10
namespace FluentAssertions . Mvc
11
11
{
12
+ /// <summary>
13
+ /// Contains a number of methods to assert that a <see cref="ViewResultBase"/> is in the expected state.
14
+ /// </summary>
12
15
[ DebuggerNonUserCode ]
13
16
public abstract class ViewResultBaseAssertions < T > : ObjectAssertions
14
17
where T : ViewResultBase
15
18
{
19
+ /// <summary>
20
+ /// Initializes a new instance of the <see cref="T:ViewResultBaseAssertions" /> class.
21
+ /// </summary>
16
22
public ViewResultBaseAssertions ( ViewResultBase subject ) : base ( subject )
17
23
{
18
24
Subject = ( T ) subject ;
19
25
}
20
26
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 )
28
39
{
29
40
string actualViewName = ( Subject as ViewResultBase ) . ViewName ;
30
41
@@ -35,13 +46,19 @@ public ViewResultBaseAssertions<T> WithViewName(string expectedViewName, string
35
46
return this ;
36
47
}
37
48
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 )
45
62
{
46
63
ViewDataDictionary actualViewData = ( Subject as ViewResultBase ) . ViewData ;
47
64
@@ -60,13 +77,19 @@ public ViewResultBaseAssertions<T> WithViewData(string key, object expectedValue
60
77
return this ;
61
78
}
62
79
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 )
70
93
{
71
94
TempDataDictionary actualTempData = ( Subject as ViewResultBase ) . TempData ;
72
95
@@ -80,6 +103,10 @@ public ViewResultBaseAssertions<T> WithTempData(string key, object expectedValue
80
103
return this ;
81
104
}
82
105
106
+
107
+ /// <summary>
108
+ /// The model.
109
+ /// </summary>
83
110
public object Model
84
111
{
85
112
get
@@ -89,6 +116,11 @@ public object Model
89
116
}
90
117
}
91
118
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>
92
124
public TModel ModelAs < TModel > ( )
93
125
{
94
126
object model = ( Subject as ViewResultBase ) . Model ;
@@ -103,13 +135,17 @@ public TModel ModelAs<TModel>()
103
135
return ( TModel ) model ;
104
136
}
105
137
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 )
113
149
{
114
150
string viewName = ( Subject as ViewResultBase ) . ViewName ;
115
151
0 commit comments