|
7 | 7 |
|
8 | 8 | namespace FluentAssertions.Mvc3
|
9 | 9 | {
|
10 |
| - public class RedirectResultAssertions : ReferenceTypeAssertions<RedirectResult, RedirectResultAssertions> |
| 10 | + public class RedirectResultAssertions : ObjectAssertions |
11 | 11 | {
|
12 |
| - public RedirectResultAssertions(RedirectResult subject) |
13 |
| - { |
14 |
| - Subject = subject; |
15 |
| - } |
| 12 | + public RedirectResultAssertions(RedirectResult subject) : base(subject) { } |
16 | 13 |
|
17 |
| - public RedirectResultAssertions HaveUrl(string expectedUrl) |
| 14 | + public RedirectResultAssertions WithUrl(string expectedUrl) |
18 | 15 | {
|
19 |
| - HaveUrl(expectedUrl, string.Empty, null); |
| 16 | + WithUrl(expectedUrl, string.Empty, null); |
20 | 17 | return this;
|
21 | 18 | }
|
22 | 19 |
|
23 |
| - public RedirectResultAssertions HaveUrl(string expectedUrl, string reason, string reasonArgs) |
| 20 | + public RedirectResultAssertions WithUrl(string expectedUrl, string reason, string reasonArgs) |
24 | 21 | {
|
| 22 | + string actualUrl = (Subject as RedirectResult).Url; |
| 23 | + |
25 | 24 | Execute.Verification
|
26 |
| - .ForCondition(string.Equals(Subject.Url, expectedUrl, StringComparison.InvariantCultureIgnoreCase)) |
| 25 | + .ForCondition(string.Equals(actualUrl, expectedUrl, StringComparison.InvariantCultureIgnoreCase)) |
27 | 26 | .BecauseOf(reason, reasonArgs)
|
28 |
| - .FailWith("Expected RedirectResult.Url to be '{0}' but was '{1}'", expectedUrl, Subject.Url); |
| 27 | + .FailWith("Expected RedirectResult.Url to be {0}{reason} but was {1}", expectedUrl, actualUrl); |
29 | 28 |
|
30 | 29 | return this;
|
31 | 30 | }
|
32 | 31 |
|
33 |
| - public RedirectResultAssertions HavePermanent(bool expectedPermanent) |
| 32 | + public RedirectResultAssertions WithPermanent(bool expectedPermanent) |
34 | 33 | {
|
35 |
| - HavePermanent(expectedPermanent, string.Empty, null); |
| 34 | + WithPermanent(expectedPermanent, string.Empty, null); |
36 | 35 | return this;
|
37 | 36 | }
|
38 | 37 |
|
39 |
| - public RedirectResultAssertions HavePermanent(bool expectedPermanent, string reason, string reasonArgs) |
| 38 | + public RedirectResultAssertions WithPermanent(bool expectedPermanent, string reason, string reasonArgs) |
40 | 39 | {
|
| 40 | + bool actualPermanent = (Subject as RedirectResult).Permanent; |
| 41 | + |
41 | 42 | Execute.Verification
|
42 |
| - .ForCondition(expectedPermanent == Subject.Permanent) |
| 43 | + .ForCondition(expectedPermanent == actualPermanent) |
43 | 44 | .BecauseOf(reason, reasonArgs)
|
44 |
| - .FailWith("Expected RedirectResult.Permanent to be '{0}' but was '{1}'", expectedPermanent, Subject.Permanent); |
| 45 | + .FailWith("Expected RedirectResult.Permanent to be {0}{reason} but was {1}", expectedPermanent, actualPermanent); |
45 | 46 |
|
46 | 47 | return this;
|
47 | 48 | }
|
|
0 commit comments