@@ -26,7 +26,7 @@ public AcceptedAtActionResultAssertions(AcceptedAtActionResult subject) : base(s
26
26
/// is needed. If the phrase does not start with the word <i>because</i>, it is prepended automatically.
27
27
/// </param>
28
28
/// <param name="reasonArgs">
29
- /// Zero or more objects to format using the placeholders in <see cref ="reason" />.
29
+ /// Zero or more objects to format using the placeholders in <paramref name ="reason"/>.
30
30
/// </param>
31
31
public AcceptedAtActionResultAssertions WithActionName ( string expectedActionName , string reason = "" , params object [ ] reasonArgs )
32
32
{
@@ -35,7 +35,8 @@ public AcceptedAtActionResultAssertions WithActionName(string expectedActionName
35
35
Execute . Assertion
36
36
. ForCondition ( string . Equals ( actualActionName , expectedActionName , StringComparison . OrdinalIgnoreCase ) )
37
37
. BecauseOf ( reason , reasonArgs )
38
- . FailWith ( "Expected AcceptedAtActionResult.ActionName to be {0}{reason} but was {1}" , expectedActionName , actualActionName ) ;
38
+ . WithDefaultIdentifier ( "AcceptedAtActionResult.ActionName" )
39
+ . FailWith ( FailureMessages . CommonFailMessage , expectedActionName , actualActionName ) ;
39
40
40
41
return this ;
41
42
}
@@ -45,11 +46,11 @@ public AcceptedAtActionResultAssertions WithActionName(string expectedActionName
45
46
/// </summary>
46
47
/// <param name="expectedControllerName">The expected controller.</param>
47
48
/// <param name="reason">
48
- /// A formatted phrase as is supported by <see cref="string.Format(string,object[])" /> explaining why the assertion
49
+ /// A formatted phrase as is supported by <see cref="string.Format(string,object[])" /> explaining why the assertion
49
50
/// is needed. If the phrase does not start with the word <i>because</i>, it is prepended automatically.
50
51
/// </param>
51
52
/// <param name="reasonArgs">
52
- /// Zero or more objects to format using the placeholders in <see cref ="reason" />.
53
+ /// Zero or more objects to format using the placeholders in <paramref name ="reason"/>.
53
54
/// </param>
54
55
public AcceptedAtActionResultAssertions WithControllerName ( string expectedControllerName , string reason = "" , params object [ ] reasonArgs )
55
56
{
@@ -58,7 +59,8 @@ public AcceptedAtActionResultAssertions WithControllerName(string expectedContro
58
59
Execute . Assertion
59
60
. ForCondition ( string . Equals ( actualControllerName , expectedControllerName , StringComparison . OrdinalIgnoreCase ) )
60
61
. BecauseOf ( reason , reasonArgs )
61
- . FailWith ( "Expected AcceptedAtActionResult.ControllerName to be {0}{reason} but was {1}" , expectedControllerName , actualControllerName ) ;
62
+ . WithDefaultIdentifier ( "AcceptedAtActionResult.ControllerName" )
63
+ . FailWith ( FailureMessages . CommonFailMessage , expectedControllerName , actualControllerName ) ;
62
64
63
65
return this ;
64
66
}
@@ -69,27 +71,18 @@ public AcceptedAtActionResultAssertions WithControllerName(string expectedContro
69
71
/// <param name="key">The expected key.</param>
70
72
/// <param name="expectedValue">The expected value.</param>
71
73
/// <param name="reason">
72
- /// A formatted phrase as is supported by <see cref="string.Format(string,object[])" /> explaining why the assertion
74
+ /// A formatted phrase as is supported by <see cref="string.Format(string,object[])" /> explaining why the assertion
73
75
/// is needed. If the phrase does not start with the word <i>because</i>, it is prepended automatically.
74
76
/// </param>
75
77
/// <param name="reasonArgs">
76
- /// Zero or more objects to format using the placeholders in <see cref ="reason" />.
78
+ /// Zero or more objects to format using the placeholders in <paramref name ="reason"/>.
77
79
/// </param>
78
80
public AcceptedAtActionResultAssertions WithRouteValue ( string key , object expectedValue , string reason = "" , params object [ ] reasonArgs )
79
81
{
80
82
var subjectTyped = Subject as AcceptedAtActionResult ;
81
83
82
- Execute . Assertion
83
- . ForCondition ( subjectTyped != null && subjectTyped . RouteValues . ContainsKey ( key ) )
84
- . BecauseOf ( reason , reasonArgs )
85
- . FailWith ( FailureMessages . AcceptedAtActionResult_RouteValues_ContainsKey , key ) ;
86
-
87
- var actualValue = subjectTyped . RouteValues [ key ] ;
88
-
89
- Execute . Assertion
90
- . ForCondition ( expectedValue . Equals ( actualValue ) )
91
- . BecauseOf ( reason , reasonArgs )
92
- . FailWith ( FailureMessages . AcceptedAtActionResult_RouteValues_HaveValue , key , expectedValue , actualValue ) ;
84
+ AssertionHelpers . AssertStringObjectDictionary ( subjectTyped . RouteValues ,
85
+ "AcceptedAtActionResult.RouteValues" , key , expectedValue , reason , reasonArgs ) ;
93
86
94
87
return this ;
95
88
}
@@ -105,11 +98,14 @@ public TValue ValueAs<TValue>()
105
98
var value = subjectTyped . Value ;
106
99
107
100
if ( value == null )
108
- Execute . Assertion . FailWith ( FailureMessages . CommonNullWasSuppliedFailMessage , "AcceptedAtActionResult.Value" , typeof ( TValue ) . Name ) ;
101
+ Execute . Assertion
102
+ . WithDefaultIdentifier ( "AcceptedAtActionResult.Value" )
103
+ . FailWith ( FailureMessages . CommonNullWasSuppliedFailMessage , typeof ( TValue ) ) ;
109
104
110
105
Execute . Assertion
111
106
. ForCondition ( value is TValue )
112
- . FailWith ( FailureMessages . CommonTypeFailMessage , "AcceptedAtActionResult.Value" , typeof ( TValue ) . Name , value . GetType ( ) . Name ) ;
107
+ . WithDefaultIdentifier ( "AcceptedAtActionResult.Value" )
108
+ . FailWith ( FailureMessages . CommonTypeFailMessage , typeof ( TValue ) , value . GetType ( ) ) ;
113
109
114
110
return ( TValue ) value ;
115
111
}
0 commit comments