Skip to content

Commit ebbbe8d

Browse files
committed
Get rid of all the compiler directives
1 parent 1043b03 commit ebbbe8d

24 files changed

+55
-1067
lines changed

src/FluentAssertions.AspNetCore.Mvc/ActionResultAssertions.cs

Lines changed: 31 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,16 @@
1+
using System.Diagnostics;
12
using FluentAssertions.Primitives;
23
using FluentAssertions.Execution;
3-
using System;
4-
#if NETSTANDARD1_6
54
using Microsoft.AspNetCore.Mvc;
6-
#else
7-
using System.Web.Mvc;
8-
#endif
9-
using System.Diagnostics;
105

116
namespace FluentAssertions.Mvc
127
{
138
/// <summary>
149
/// Contains a number of methods to assert that an <see cref="ActionResult"/> is in the expected state.
1510
/// </summary>
1611
[DebuggerNonUserCode]
17-
public class ActionResultAssertions : ObjectAssertions
18-
{
12+
public class ActionResultAssertions : ObjectAssertions
13+
{
1914
public struct Constants
2015
{
2116
public const string CommonFailMessage = "Expected ActionResult to be {0}{reason}, but found {1}";
@@ -24,17 +19,15 @@ public struct Constants
2419
/// <summary>
2520
/// Initializes a new instance of the <see cref="T:ActionResultAssertions" /> class.
2621
/// </summary>
27-
public ActionResultAssertions (ActionResult subject) : base(subject)
28-
{
29-
Subject = subject;
30-
}
22+
public ActionResultAssertions (ActionResult subject) : base(subject)
23+
{
24+
Subject = subject;
25+
}
3126

32-
#if NETSTANDARD1_6
3327
public ActionResultAssertions (IActionResult subject): base(subject)
3428
{
3529
Subject = subject;
3630
}
37-
#endif
3831

3932
/// <summary>
4033
/// Asserts that the subject is a <see cref="ContentResult"/>.
@@ -57,9 +50,9 @@ public ContentResultAssertions BeContentResult()
5750
public ContentResultAssertions BeContentResult(string reason, params object[] reasonArgs)
5851
{
5952
Execute.Assertion
60-
.BecauseOf(reason, reasonArgs)
61-
.ForCondition(Subject is ContentResult)
62-
.FailWith(Constants.CommonFailMessage, typeof(ContentResult).Name, Subject.GetType().Name);
53+
.BecauseOf(reason, reasonArgs)
54+
.ForCondition(Subject is ContentResult)
55+
.FailWith(Constants.CommonFailMessage, typeof(ContentResult).Name, Subject.GetType().Name);
6356

6457
return new ContentResultAssertions(Subject as ContentResult);
6558
}
@@ -85,9 +78,9 @@ public EmptyResult BeEmptyResult()
8578
public EmptyResult BeEmptyResult(string reason, params object[] reasonArgs)
8679
{
8780
Execute.Assertion
88-
.BecauseOf(reason, reasonArgs)
89-
.ForCondition(Subject is EmptyResult)
90-
.FailWith(Constants.CommonFailMessage, typeof(EmptyResult).Name, Subject.GetType().Name);
81+
.BecauseOf(reason, reasonArgs)
82+
.ForCondition(Subject is EmptyResult)
83+
.FailWith(Constants.CommonFailMessage, typeof(EmptyResult).Name, Subject.GetType().Name);
9184

9285
return Subject as EmptyResult;
9386
}
@@ -113,9 +106,9 @@ public RedirectToRouteAssertions BeRedirectToRouteResult()
113106
public RedirectToRouteAssertions BeRedirectToRouteResult(string reason, params object[] reasonArgs)
114107
{
115108
Execute.Assertion
116-
.BecauseOf(reason, reasonArgs)
117-
.ForCondition(Subject is RedirectToRouteResult)
118-
.FailWith(Constants.CommonFailMessage, typeof(RedirectToRouteResult).Name, Subject.GetType().Name);
109+
.BecauseOf(reason, reasonArgs)
110+
.ForCondition(Subject is RedirectToRouteResult)
111+
.FailWith(Constants.CommonFailMessage, typeof(RedirectToRouteResult).Name, Subject.GetType().Name);
119112

120113
return new RedirectToRouteAssertions(Subject as RedirectToRouteResult);
121114
}
@@ -141,9 +134,9 @@ public PartialViewResultAssertions BePartialViewResult()
141134
public PartialViewResultAssertions BePartialViewResult(string reason, params object[] reasonArgs)
142135
{
143136
Execute.Assertion
144-
.BecauseOf(reason, reasonArgs)
145-
.ForCondition(Subject is PartialViewResult)
146-
.FailWith(Constants.CommonFailMessage, typeof(PartialViewResult).Name, Subject.GetType().Name);
137+
.BecauseOf(reason, reasonArgs)
138+
.ForCondition(Subject is PartialViewResult)
139+
.FailWith(Constants.CommonFailMessage, typeof(PartialViewResult).Name, Subject.GetType().Name);
147140

148141
return new PartialViewResultAssertions(Subject as PartialViewResult);
149142
}
@@ -169,9 +162,9 @@ public RedirectResultAssertions BeRedirectResult()
169162
public RedirectResultAssertions BeRedirectResult(string reason, params object[] reasonArgs)
170163
{
171164
Execute.Assertion
172-
.BecauseOf(reason, reasonArgs)
173-
.ForCondition(Subject is RedirectResult)
174-
.FailWith(Constants.CommonFailMessage, "RedirectResult", Subject.GetType().Name);
165+
.BecauseOf(reason, reasonArgs)
166+
.ForCondition(Subject is RedirectResult)
167+
.FailWith(Constants.CommonFailMessage, "RedirectResult", Subject.GetType().Name);
175168

176169
return new RedirectResultAssertions(Subject as RedirectResult);
177170
}
@@ -195,13 +188,13 @@ public ViewResultAssertions BeViewResult()
195188
/// Zero or more objects to format using the placeholders in <see cref="reason" />.
196189
/// </param>
197190
public ViewResultAssertions BeViewResult(string reason, params object[] reasonArgs)
198-
{
199-
Execute.Assertion
200-
.BecauseOf(reason, reasonArgs)
201-
.ForCondition (Subject is ViewResult)
202-
.FailWith(Constants.CommonFailMessage, "ViewResult", Subject.GetType().Name);
191+
{
192+
Execute.Assertion
193+
.BecauseOf(reason, reasonArgs)
194+
.ForCondition (Subject is ViewResult)
195+
.FailWith(Constants.CommonFailMessage, "ViewResult", Subject.GetType().Name);
203196

204-
return new ViewResultAssertions (Subject as ViewResult);
205-
}
206-
}
207-
}
197+
return new ViewResultAssertions (Subject as ViewResult);
198+
}
199+
}
200+
}

src/FluentAssertions.AspNetCore.Mvc/AssertionsExtensions.cs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
1-
using FluentAssertions;
2-
using System;
3-
#if NETSTANDARD1_6
1+
using System.Diagnostics;
42
using Microsoft.AspNetCore.Mvc;
53
using Microsoft.AspNetCore.Routing;
6-
#else
7-
using System.Web.Mvc;
8-
using System.Web.Routing;
9-
#endif
10-
using FluentAssertions.Mvc;
11-
using System.Diagnostics;
124

135
namespace FluentAssertions.Mvc
146
{
@@ -27,7 +19,6 @@ public static ActionResultAssertions Should (this ActionResult actual)
2719
return new ActionResultAssertions (actual);
2820
}
2921

30-
#if NETSTANDARD1_6
3122
/// <summary>
3223
/// Returns an <see cref="ActionResultAssertions"/> object that can be used to assert the
3324
/// current <see cref="IActionResult"/>.
@@ -36,7 +27,6 @@ public static ActionResultAssertions Should (this IActionResult actual)
3627
{
3728
return new ActionResultAssertions (actual);
3829
}
39-
#endif
4030

4131
/// <summary>
4232
/// Returns an <see cref="RouteDataAssertions"/> object that can be used to assert the
Lines changed: 8 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,7 @@
1-
using FluentAssertions.Execution;
1+
using System;
2+
using FluentAssertions.Execution;
23
using FluentAssertions.Primitives;
3-
using System;
4-
using System.Collections.Generic;
5-
using System.Linq;
6-
using System.Text;
7-
#if NETSTANDARD1_6
84
using Microsoft.AspNetCore.Mvc;
9-
#else
10-
using System.Web.Mvc;
11-
#endif
125

136
namespace FluentAssertions.Mvc
147
{
@@ -40,13 +33,9 @@ public ContentResultAssertions WithContent(string expectedContent, string reason
4033
string actualContent = (Subject as ContentResult).Content;
4134

4235
Execute.Assertion
43-
#if NETSTANDARD1_6
44-
.ForCondition(string.Equals(actualContent, expectedContent, StringComparison.OrdinalIgnoreCase))
45-
#else
46-
.ForCondition(string.Equals(actualContent, expectedContent, StringComparison.InvariantCultureIgnoreCase))
47-
#endif
48-
.BecauseOf(reason, reasonArgs)
49-
.FailWith(string.Format(FailureMessages.CommonFailMessage, "ContentResult.Content", expectedContent, actualContent));
36+
.ForCondition(string.Equals(actualContent, expectedContent, StringComparison.OrdinalIgnoreCase))
37+
.BecauseOf(reason, reasonArgs)
38+
.FailWith(string.Format(FailureMessages.CommonFailMessage, "ContentResult.Content", expectedContent, actualContent));
5039

5140
return this;
5241
}
@@ -67,41 +56,11 @@ public ContentResultAssertions WithContentType(string expectedContentType, strin
6756
string actualContentType = (Subject as ContentResult).ContentType;
6857

6958
Execute.Assertion
70-
#if NETSTANDARD1_6
71-
.ForCondition(string.Equals(expectedContentType, actualContentType, StringComparison.OrdinalIgnoreCase))
72-
#else
73-
.ForCondition(string.Equals(expectedContentType, actualContentType, StringComparison.InvariantCultureIgnoreCase))
74-
#endif
75-
.BecauseOf(reason, reasonArgs)
76-
.FailWith(string.Format(FailureMessages.CommonFailMessage, "ContentResult.ContentType", expectedContentType, actualContentType));
59+
.ForCondition(string.Equals(expectedContentType, actualContentType, StringComparison.OrdinalIgnoreCase))
60+
.BecauseOf(reason, reasonArgs)
61+
.FailWith(string.Format(FailureMessages.CommonFailMessage, "ContentResult.ContentType", expectedContentType, actualContentType));
7762

7863
return this;
7964
}
80-
81-
// ContentEncoding seems to have vanished from .NetCore... weird.
82-
#if !NETSTANDARD1_6
83-
/// <summary>
84-
/// Asserts that the content encoding is the expected content encoding type.
85-
/// </summary>
86-
/// <param name="expectedEncoding">The expected content encoding type.</param>
87-
/// <param name="reason">
88-
/// A formatted phrase as is supported by <see cref="string.Format(string,object[])" /> explaining why the assertion
89-
/// is needed. If the phrase does not start with the word <i>because</i>, it is prepended automatically.
90-
/// </param>
91-
/// <param name="reasonArgs">
92-
/// Zero or more objects to format using the placeholders in <see cref="reason" />.
93-
/// </param>
94-
public ContentResultAssertions WithContentEncoding(Encoding expectedEncoding, string reason = "", params object[] reasonArgs)
95-
{
96-
Encoding actualContentEncoding = (Subject as ContentResult).ContentEncoding;
97-
98-
Execute.Assertion
99-
.ForCondition(expectedEncoding == actualContentEncoding)
100-
.BecauseOf(reason, reasonArgs)
101-
.FailWith(string.Format(FailureMessages.CommonFailMessage, "ContentResult.ContentEncoding", expectedEncoding.ToString(), actualContentEncoding.ToString()));
102-
103-
return this;
104-
}
105-
#endif
10665
}
10766
}

src/FluentAssertions.AspNetCore.Mvc/ControllerAssertions.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using System;
21
using System.Diagnostics;
32

43
namespace FluentAssertions.Mvc

src/FluentAssertions.AspNetCore.Mvc/Fakes/FakeHttpContext.cs

Lines changed: 0 additions & 130 deletions
This file was deleted.

0 commit comments

Comments
 (0)