@@ -10,11 +10,6 @@ namespace FluentAssertions.Mvc3
10
10
{
11
11
public class RedirectToRouteAssertions : ReferenceTypeAssertions < RedirectToRouteResult , RedirectToRouteAssertions >
12
12
{
13
- public class Constants
14
- {
15
- public const string CommonFailMessage = "Expected RedirectResult.{0} to be '{1}' but was '{2}'" ;
16
- }
17
-
18
13
public RedirectToRouteAssertions ( RedirectToRouteResult subject )
19
14
{
20
15
Subject = subject ;
@@ -29,10 +24,9 @@ public RedirectToRouteAssertions WithPermanent(bool expectedPermanent)
29
24
public RedirectToRouteAssertions WithPermanent ( bool expectedPermanent , string reason , params object [ ] reasonArgs )
30
25
{
31
26
Execute . Verification
32
- . ForCondition ( expectedPermanent == Subject . Permanent )
33
27
. BecauseOf ( reason , reasonArgs )
34
- . FailWith ( Constants . CommonFailMessage , "Permanent" , expectedPermanent , Subject . Permanent ) ;
35
-
28
+ . ForCondition ( expectedPermanent == Subject . Permanent )
29
+ . FailWith ( "Expected RedirectToRoute.Permanent to be {0}{reason}, but found {1}" , expectedPermanent , Subject . Permanent ) ;
36
30
return this ;
37
31
}
38
32
@@ -45,13 +39,25 @@ public RedirectToRouteAssertions WithRouteName(string expectedRouteName)
45
39
public RedirectToRouteAssertions WithRouteName ( string expectedRouteName , string reason , params object [ ] reasonArgs )
46
40
{
47
41
Execute . Verification
48
- . ForCondition ( string . Equals ( expectedRouteName , Subject . RouteName , StringComparison . InvariantCultureIgnoreCase ) )
49
42
. BecauseOf ( reason , reasonArgs )
50
- . FailWith ( Constants . CommonFailMessage , "RouteName" , expectedRouteName , Subject . Permanent ) ;
43
+ . ForCondition ( string . Equals ( expectedRouteName , Subject . RouteName , StringComparison . InvariantCultureIgnoreCase ) )
44
+ . FailWith ( "Expected RedirectToRoute.RouteName to be {0}{reason}, but found {1}" , expectedRouteName , Subject . RouteName ) ;
51
45
52
46
return this ;
53
47
}
54
48
49
+ public RedirectToRouteAssertions WithRouteValue ( string key , object expectedValue )
50
+ {
51
+ WithRouteValue ( key , expectedValue , string . Empty , null ) ;
52
+ return this ;
53
+ }
54
+
55
+ public RedirectToRouteAssertions WithRouteValue ( string key , object expectedValue , string reason , params object [ ] reasonArgs )
56
+ {
57
+ Subject . RouteValues . Should ( ) . Contain ( new KeyValuePair < string , object > ( key , expectedValue ) , reason , reasonArgs ) ;
58
+ return this ;
59
+ }
60
+
55
61
public RedirectToRouteAssertions WithController ( string expectedControllerName )
56
62
{
57
63
WithController ( expectedControllerName , string . Empty , null ) ;
@@ -60,27 +66,31 @@ public RedirectToRouteAssertions WithController(string expectedControllerName)
60
66
61
67
public RedirectToRouteAssertions WithController ( string expectedControllerName , string reason , params object [ ] reasonArgs )
62
68
{
63
- //Subject.RouteValues[""]
64
-
69
+ WithRouteValue ( "Controller" , expectedControllerName , reason , reasonArgs ) ;
65
70
return this ;
66
71
}
67
72
68
- public RedirectToRouteAssertions WithRouteValue ( string key , object expectedValue )
73
+ public RedirectToRouteAssertions WithAction ( string expectedAction )
69
74
{
70
- WithRouteValue ( key , expectedValue , string . Empty , null ) ;
75
+ WithAction ( expectedAction , string . Empty , null ) ;
71
76
return this ;
72
77
}
73
78
74
- public RedirectToRouteAssertions WithRouteValue ( string key , object expectedValue , string reason , params object [ ] reasonArgs )
79
+ public RedirectToRouteAssertions WithAction ( string expectedArea , string reason , params object [ ] reasonArgs )
75
80
{
76
- Execute . Verification
77
- . ForCondition ( Subject . RouteValues . ContainsKey ( key ) )
78
- . BecauseOf ( reason , reasonArgs )
79
- . FailWith ( string . Format ( "RedirectResult.RouteValues does not contain key '{0}'" , key ) ) ;
80
-
81
- var actualValue = Subject . RouteValues [ key ] ;
82
- actualValue . Should ( ) . Be ( expectedValue ) ;
81
+ WithRouteValue ( "Action" , expectedArea , reason , reasonArgs ) ;
82
+ return this ;
83
+ }
83
84
85
+ public RedirectToRouteAssertions WithArea ( string expectedAction )
86
+ {
87
+ WithArea ( expectedAction , string . Empty , null ) ;
88
+ return this ;
89
+ }
90
+
91
+ public RedirectToRouteAssertions WithArea ( string expectedArea , string reason , params object [ ] reasonArgs )
92
+ {
93
+ WithRouteValue ( "Area" , expectedArea , reason , reasonArgs ) ;
84
94
return this ;
85
95
}
86
96
}
0 commit comments