@@ -10,7 +10,7 @@ namespace FluentAssertions.AspNetCore.Mvc
10
10
/// Contains a number of methods to assert that a <see cref="AcceptedAtActionResult"/> is in the expected state.
11
11
/// </summary>
12
12
[ DebuggerNonUserCode ]
13
- public class AcceptedAtActionResultAssertions : ObjectAssertions
13
+ public class AcceptedAtActionResultAssertions : ObjectResultAssertionsBase < AcceptedAtActionResult , AcceptedAtActionResultAssertions >
14
14
{
15
15
/// <summary>
16
16
/// Initializes a new instance of the <see cref="AcceptedAtActionResultAssertions" /> class.
@@ -30,7 +30,7 @@ public AcceptedAtActionResultAssertions(AcceptedAtActionResult subject) : base(s
30
30
/// </param>
31
31
public AcceptedAtActionResultAssertions WithActionName ( string expectedActionName , string reason = "" , params object [ ] reasonArgs )
32
32
{
33
- string actualActionName = ( Subject as AcceptedAtActionResult ) ? . ActionName ;
33
+ string actualActionName = ObjectResultSubject ? . ActionName ;
34
34
35
35
Execute . Assertion
36
36
. ForCondition ( string . Equals ( actualActionName , expectedActionName , StringComparison . OrdinalIgnoreCase ) )
@@ -54,7 +54,7 @@ public AcceptedAtActionResultAssertions WithActionName(string expectedActionName
54
54
/// </param>
55
55
public AcceptedAtActionResultAssertions WithControllerName ( string expectedControllerName , string reason = "" , params object [ ] reasonArgs )
56
56
{
57
- string actualControllerName = ( Subject as AcceptedAtActionResult ) ? . ControllerName ;
57
+ string actualControllerName = ObjectResultSubject ? . ControllerName ;
58
58
59
59
Execute . Assertion
60
60
. ForCondition ( string . Equals ( actualControllerName , expectedControllerName , StringComparison . OrdinalIgnoreCase ) )
@@ -79,35 +79,12 @@ public AcceptedAtActionResultAssertions WithControllerName(string expectedContro
79
79
/// </param>
80
80
public AcceptedAtActionResultAssertions WithRouteValue ( string key , object expectedValue , string reason = "" , params object [ ] reasonArgs )
81
81
{
82
- var subjectTyped = Subject as AcceptedAtActionResult ;
82
+ var actualRouteValues = ObjectResultSubject . RouteValues ;
83
83
84
- AssertionHelpers . AssertStringObjectDictionary ( subjectTyped . RouteValues ,
84
+ AssertionHelpers . AssertStringObjectDictionary ( actualRouteValues ,
85
85
"AcceptedAtActionResult.RouteValues" , key , expectedValue , reason , reasonArgs ) ;
86
86
87
87
return this ;
88
88
}
89
-
90
- /// <summary>
91
- /// Asserts the value is of the expected type.
92
- /// </summary>
93
- /// <typeparam name="TValue">The expected type.</typeparam>
94
- /// <returns>The typed value.</returns>
95
- public TValue ValueAs < TValue > ( )
96
- {
97
- var subjectTyped = Subject as AcceptedAtActionResult ;
98
- var value = subjectTyped . Value ;
99
-
100
- if ( value == null )
101
- Execute . Assertion
102
- . WithDefaultIdentifier ( "AcceptedAtActionResult.Value" )
103
- . FailWith ( FailureMessages . CommonNullWasSuppliedFailMessage , typeof ( TValue ) ) ;
104
-
105
- Execute . Assertion
106
- . ForCondition ( value is TValue )
107
- . WithDefaultIdentifier ( "AcceptedAtActionResult.Value" )
108
- . FailWith ( FailureMessages . CommonTypeFailMessage , typeof ( TValue ) , value . GetType ( ) ) ;
109
-
110
- return ( TValue ) value ;
111
- }
112
89
}
113
90
}
0 commit comments