8
8
9
9
namespace FluentAssertions . Mvc
10
10
{
11
+ /// <summary>
12
+ /// Contains a number of methods to assert that a <see cref="ContentResult"/> is in the expected state.
13
+ /// </summary>
11
14
public class ContentResultAssertions : ObjectAssertions
12
15
{
16
+ /// <summary>
17
+ /// Initializes a new instance of the <see cref="T:ContentResultAssertions" /> class.
18
+ /// </summary>
13
19
public ContentResultAssertions ( ContentResult subject ) : base ( subject )
14
20
{
15
21
}
16
22
17
- public ContentResultAssertions WithContent ( string expectedContent )
18
- {
19
- WithContent ( expectedContent , string . Empty , null ) ;
20
- return this ;
21
- }
22
-
23
- public ContentResultAssertions WithContent ( string expectedContent , string reason , params object [ ] reasonArgs )
23
+ /// <summary>
24
+ /// Asserts that the content is exactly the same as the expected content, ignoring the casing.
25
+ /// </summary>
26
+ /// <param name="expectedContent">The expected content string.</param>
27
+ /// <param name="reason">
28
+ /// A formatted phrase as is supported by <see cref="string.Format(string,object[])" /> explaining why the assertion
29
+ /// is needed. If the phrase does not start with the word <i>because</i>, it is prepended automatically.
30
+ /// </param>
31
+ /// <param name="reasonArgs">
32
+ /// Zero or more objects to format using the placeholders in <see cref="reason" />.
33
+ /// </param>
34
+ public ContentResultAssertions WithContent ( string expectedContent , string reason = "" , params object [ ] reasonArgs )
24
35
{
25
36
string actualContent = ( Subject as ContentResult ) . Content ;
26
37
@@ -32,38 +43,48 @@ public ContentResultAssertions WithContent(string expectedContent, string reason
32
43
return this ;
33
44
}
34
45
35
- public ContentResultAssertions WithContentType ( string expectedContent )
36
- {
37
- WithContentType ( expectedContent , string . Empty , null ) ;
38
- return this ;
39
- }
40
-
41
- public ContentResultAssertions WithContentType ( string expectedContent , string reason , params object [ ] reasonArgs )
46
+ /// <summary>
47
+ /// Asserts that the content type is the expected content type.
48
+ /// </summary>
49
+ /// <param name="expectedContentType">The expected content type.</param>
50
+ /// <param name="reason">
51
+ /// A formatted phrase as is supported by <see cref="string.Format(string,object[])" /> explaining why the assertion
52
+ /// is needed. If the phrase does not start with the word <i>because</i>, it is prepended automatically.
53
+ /// </param>
54
+ /// <param name="reasonArgs">
55
+ /// Zero or more objects to format using the placeholders in <see cref="reason" />.
56
+ /// </param>
57
+ public ContentResultAssertions WithContentType ( string expectedContentType , string reason = "" , params object [ ] reasonArgs )
42
58
{
43
59
string actualContentType = ( Subject as ContentResult ) . ContentType ;
44
60
45
61
Execute . Verification
46
- . ForCondition ( string . Equals ( expectedContent , actualContentType , StringComparison . InvariantCultureIgnoreCase ) )
62
+ . ForCondition ( string . Equals ( expectedContentType , actualContentType , StringComparison . InvariantCultureIgnoreCase ) )
47
63
. BecauseOf ( reason , reasonArgs )
48
- . FailWith ( string . Format ( FailureMessages . CommonFailMessage , "ContentResult.ContentType" , expectedContent , actualContentType ) ) ;
49
-
50
- return this ;
51
- }
64
+ . FailWith ( string . Format ( FailureMessages . CommonFailMessage , "ContentResult.ContentType" , expectedContentType , actualContentType ) ) ;
52
65
53
- public ContentResultAssertions WithContentEncoding ( Encoding expectedEncoding )
54
- {
55
- WithContentEncoding ( expectedEncoding , string . Empty , null ) ;
56
66
return this ;
57
67
}
58
68
59
- public ContentResultAssertions WithContentEncoding ( Encoding expectedEncoding , string reason , params object [ ] reasonArgs )
69
+ /// <summary>
70
+ /// Asserts that the content encoding is the expected content encoding type.
71
+ /// </summary>
72
+ /// <param name="expectedEncoding">The expected content encoding type.</param>
73
+ /// <param name="reason">
74
+ /// A formatted phrase as is supported by <see cref="string.Format(string,object[])" /> explaining why the assertion
75
+ /// is needed. If the phrase does not start with the word <i>because</i>, it is prepended automatically.
76
+ /// </param>
77
+ /// <param name="reasonArgs">
78
+ /// Zero or more objects to format using the placeholders in <see cref="reason" />.
79
+ /// </param>
80
+ public ContentResultAssertions WithContentEncoding ( Encoding expectedEncoding , string reason = "" , params object [ ] reasonArgs )
60
81
{
61
82
Encoding actualContentEncoding = ( Subject as ContentResult ) . ContentEncoding ;
62
83
63
84
Execute . Verification
64
85
. ForCondition ( expectedEncoding == actualContentEncoding )
65
86
. BecauseOf ( reason , reasonArgs )
66
- . FailWith ( string . Format ( FailureMessages . CommonFailMessage , "ContentResult.ContentType " , expectedEncoding . ToString ( ) , actualContentEncoding . ToString ( ) ) ) ;
87
+ . FailWith ( string . Format ( FailureMessages . CommonFailMessage , "ContentResult.ContentEncoding " , expectedEncoding . ToString ( ) , actualContentEncoding . ToString ( ) ) ) ;
67
88
68
89
return this ;
69
90
}
0 commit comments