From fdca6133613660abc275787d98e2e28b0672fb01 Mon Sep 17 00:00:00 2001 From: Rik Crompton Date: Thu, 21 Jun 2018 16:56:39 +0100 Subject: [PATCH] Removed compiler directives for .NET Core --- .../ActionResultAssertions.cs | 12 ---- .../AssertionsExtensions.cs | 19 ------ .../ContentResultAssertions.cs | 29 ++------- .../FailureMessages.Designer.cs | 4 +- .../Fakes/FakeHttpContext.cs | 4 +- .../Fakes/FakeHttpRequest.cs | 4 +- .../Fakes/FakeHttpResponse.cs | 4 +- .../PartialViewResultAssertions.cs | 9 +-- .../RedirectResultAssertions.cs | 23 ++----- .../RedirectToRouteAssertions.cs | 23 ++----- .../RouteCollection_Extensions.cs | 8 +-- .../RouteDataAssertions.cs | 35 ++++------- .../RouteValueDictionary_Extensions.cs | 4 +- .../ViewResultAssertions.cs | 2 - .../ViewResultBaseAssertions.cs | 7 +-- .../ContentResultAssertions_Tests.cs | 9 --- .../Fakes/FakeController.cs | 6 +- .../PartialViewResultAssertions_Tests.cs | 30 ++------- .../RedirectResultAssertions_Tests.cs | 4 -- .../RedirectToRoute_Tests.cs | 5 -- .../RouteDataAssertions_Tests.cs | 4 +- .../RouteValueDictionary_Extensions_Tests.cs | 8 +-- .../ViewResultAssertions_Tests.cs | 63 ------------------- 23 files changed, 47 insertions(+), 269 deletions(-) diff --git a/src/FluentAssertions.Mvc.Shared/ActionResultAssertions.cs b/src/FluentAssertions.Mvc.Shared/ActionResultAssertions.cs index 333935b..ad1a776 100644 --- a/src/FluentAssertions.Mvc.Shared/ActionResultAssertions.cs +++ b/src/FluentAssertions.Mvc.Shared/ActionResultAssertions.cs @@ -1,11 +1,6 @@ using FluentAssertions.Primitives; using FluentAssertions.Execution; -using System; -#if NETSTANDARD1_6 -using Microsoft.AspNetCore.Mvc; -#else using System.Web.Mvc; -#endif using System.Diagnostics; namespace FluentAssertions.Mvc @@ -35,13 +30,6 @@ public ActionResultAssertions (ActionResult subject) : base(subject) Subject = subject; } -#if NETSTANDARD1_6 - public ActionResultAssertions (IActionResult subject): base(subject) - { - Subject = subject; - } -#endif - /// /// Asserts that the subject is a . /// diff --git a/src/FluentAssertions.Mvc.Shared/AssertionsExtensions.cs b/src/FluentAssertions.Mvc.Shared/AssertionsExtensions.cs index 40749da..1f9b290 100644 --- a/src/FluentAssertions.Mvc.Shared/AssertionsExtensions.cs +++ b/src/FluentAssertions.Mvc.Shared/AssertionsExtensions.cs @@ -1,13 +1,5 @@ -using FluentAssertions; -using System; -#if NETSTANDARD1_6 -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Routing; -#else using System.Web.Mvc; using System.Web.Routing; -#endif -using FluentAssertions.Mvc; using System.Diagnostics; namespace FluentAssertions.Mvc @@ -27,17 +19,6 @@ public static ActionResultAssertions Should (this ActionResult actual) return new ActionResultAssertions (actual); } -#if NETSTANDARD1_6 - /// - /// Returns an object that can be used to assert the - /// current . - /// - public static ActionResultAssertions Should (this IActionResult actual) - { - return new ActionResultAssertions (actual); - } -#endif - /// /// Returns an object that can be used to assert the /// current . diff --git a/src/FluentAssertions.Mvc.Shared/ContentResultAssertions.cs b/src/FluentAssertions.Mvc.Shared/ContentResultAssertions.cs index bda9b53..774eaa1 100644 --- a/src/FluentAssertions.Mvc.Shared/ContentResultAssertions.cs +++ b/src/FluentAssertions.Mvc.Shared/ContentResultAssertions.cs @@ -1,14 +1,8 @@ using FluentAssertions.Execution; using FluentAssertions.Primitives; using System; -using System.Collections.Generic; -using System.Linq; using System.Text; -#if NETSTANDARD1_6 -using Microsoft.AspNetCore.Mvc; -#else using System.Web.Mvc; -#endif namespace FluentAssertions.Mvc { @@ -40,13 +34,9 @@ public ContentResultAssertions WithContent(string expectedContent, string reason string actualContent = (Subject as ContentResult).Content; Execute.Assertion -#if NETSTANDARD1_6 - .ForCondition(string.Equals(actualContent, expectedContent, StringComparison.OrdinalIgnoreCase)) -#else - .ForCondition(string.Equals(actualContent, expectedContent, StringComparison.InvariantCultureIgnoreCase)) -#endif - .BecauseOf(reason, reasonArgs) - .FailWith(string.Format(FailureMessages.CommonFailMessage, "ContentResult.Content", expectedContent, actualContent)); + .ForCondition(string.Equals(actualContent, expectedContent, StringComparison.InvariantCultureIgnoreCase)) + .BecauseOf(reason, reasonArgs) + .FailWith(string.Format(FailureMessages.CommonFailMessage, "ContentResult.Content", expectedContent, actualContent)); return this; } @@ -67,19 +57,13 @@ public ContentResultAssertions WithContentType(string expectedContentType, strin string actualContentType = (Subject as ContentResult).ContentType; Execute.Assertion -#if NETSTANDARD1_6 - .ForCondition(string.Equals(expectedContentType, actualContentType, StringComparison.OrdinalIgnoreCase)) -#else - .ForCondition(string.Equals(expectedContentType, actualContentType, StringComparison.InvariantCultureIgnoreCase)) -#endif - .BecauseOf(reason, reasonArgs) - .FailWith(string.Format(FailureMessages.CommonFailMessage, "ContentResult.ContentType", expectedContentType, actualContentType)); + .ForCondition(string.Equals(expectedContentType, actualContentType, StringComparison.InvariantCultureIgnoreCase)) + .BecauseOf(reason, reasonArgs) + .FailWith(string.Format(FailureMessages.CommonFailMessage, "ContentResult.ContentType", expectedContentType, actualContentType)); return this; } - // ContentEncoding seems to have vanished from .NetCore... weird. -#if !NETSTANDARD1_6 /// /// Asserts that the content encoding is the expected content encoding type. /// @@ -102,6 +86,5 @@ public ContentResultAssertions WithContentEncoding(Encoding expectedEncoding, st return this; } -#endif } } diff --git a/src/FluentAssertions.Mvc.Shared/FailureMessages.Designer.cs b/src/FluentAssertions.Mvc.Shared/FailureMessages.Designer.cs index a262f5f..f392d2f 100644 --- a/src/FluentAssertions.Mvc.Shared/FailureMessages.Designer.cs +++ b/src/FluentAssertions.Mvc.Shared/FailureMessages.Designer.cs @@ -1,5 +1,4 @@ -#if !NETSTANDARD1_6 -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by a tool. // Runtime Version:4.0.30319.34014 @@ -162,4 +161,3 @@ internal static string ViewResultBase_WithDefaultViewName { } } } -#endif \ No newline at end of file diff --git a/src/FluentAssertions.Mvc.Shared/Fakes/FakeHttpContext.cs b/src/FluentAssertions.Mvc.Shared/Fakes/FakeHttpContext.cs index 0a3041e..c71e8e5 100644 --- a/src/FluentAssertions.Mvc.Shared/Fakes/FakeHttpContext.cs +++ b/src/FluentAssertions.Mvc.Shared/Fakes/FakeHttpContext.cs @@ -1,5 +1,4 @@ -#if !NETSTANDARD1_6 -using System; +using System; using System.Web; namespace FluentAssertions.Mvc.Fakes @@ -138,4 +137,3 @@ public override void EndOfRequest() } -#endif \ No newline at end of file diff --git a/src/FluentAssertions.Mvc.Shared/Fakes/FakeHttpRequest.cs b/src/FluentAssertions.Mvc.Shared/Fakes/FakeHttpRequest.cs index 8d75258..12777f4 100644 --- a/src/FluentAssertions.Mvc.Shared/Fakes/FakeHttpRequest.cs +++ b/src/FluentAssertions.Mvc.Shared/Fakes/FakeHttpRequest.cs @@ -1,5 +1,4 @@ -#if !NETSTANDARD1_6 -using System.Web; +using System.Web; using System.Collections.Specialized; namespace FluentAssertions.Mvc.Fakes @@ -71,4 +70,3 @@ public override NameValueCollection ServerVariables } } } -#endif \ No newline at end of file diff --git a/src/FluentAssertions.Mvc.Shared/Fakes/FakeHttpResponse.cs b/src/FluentAssertions.Mvc.Shared/Fakes/FakeHttpResponse.cs index a7813a8..66ed711 100644 --- a/src/FluentAssertions.Mvc.Shared/Fakes/FakeHttpResponse.cs +++ b/src/FluentAssertions.Mvc.Shared/Fakes/FakeHttpResponse.cs @@ -1,5 +1,4 @@ -#if !NETSTANDARD1_6 -using System.Web; +using System.Web; namespace FluentAssertions.Mvc.Fakes { @@ -15,4 +14,3 @@ public override string ApplyAppPathModifier(string virtualPath) } } } -#endif \ No newline at end of file diff --git a/src/FluentAssertions.Mvc.Shared/PartialViewResultAssertions.cs b/src/FluentAssertions.Mvc.Shared/PartialViewResultAssertions.cs index 591f8f3..e129e51 100644 --- a/src/FluentAssertions.Mvc.Shared/PartialViewResultAssertions.cs +++ b/src/FluentAssertions.Mvc.Shared/PartialViewResultAssertions.cs @@ -1,11 +1,5 @@ -#if !NETSTANDARD1_6 -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Web.Mvc; +using System.Web.Mvc; using System.Diagnostics; -using FluentAssertions.Primitives; namespace FluentAssertions.Mvc { @@ -22,4 +16,3 @@ public class PartialViewResultAssertions : ViewResultBaseAssertions WithDefaultViewName(string reason = "", param } } } -#endif \ No newline at end of file diff --git a/tests/FluentAssertions.Mvc.Tests.Shared/ContentResultAssertions_Tests.cs b/tests/FluentAssertions.Mvc.Tests.Shared/ContentResultAssertions_Tests.cs index 66a9173..b547cea 100644 --- a/tests/FluentAssertions.Mvc.Tests.Shared/ContentResultAssertions_Tests.cs +++ b/tests/FluentAssertions.Mvc.Tests.Shared/ContentResultAssertions_Tests.cs @@ -1,14 +1,7 @@ using System; -using System.Collections.Generic; -using System.Linq; using System.Text; using NUnit.Framework; - -#if NETCOREAPP1_0 -using Microsoft.AspNetCore.Mvc; -#else using System.Web.Mvc; -#endif namespace FluentAssertions.Mvc.Tests { @@ -57,7 +50,6 @@ public void WithContentType_GivenUnexpected_ShouldFail() .WithMessage(failureMessage); } -#if !NETCOREAPP1_0 [Test] public void WithContentEncoding_GivenExpected_ShouldPass() { @@ -78,6 +70,5 @@ public void WithContentEncoding_GivenUnexpected_ShouldFail() a.Should().Throw() .WithMessage(failureMessage); } -#endif } } diff --git a/tests/FluentAssertions.Mvc.Tests.Shared/Fakes/FakeController.cs b/tests/FluentAssertions.Mvc.Tests.Shared/Fakes/FakeController.cs index ae435c0..98eb2c2 100644 --- a/tests/FluentAssertions.Mvc.Tests.Shared/Fakes/FakeController.cs +++ b/tests/FluentAssertions.Mvc.Tests.Shared/Fakes/FakeController.cs @@ -1,9 +1,5 @@ -using System; -#if NETCOREAPP1_0 -using Microsoft.AspNetCore.Mvc; -#else using System.Web.Mvc; -#endif + namespace FluentAssertions.Mvc.Tests.Fakes { public class FakeController : Controller diff --git a/tests/FluentAssertions.Mvc.Tests.Shared/PartialViewResultAssertions_Tests.cs b/tests/FluentAssertions.Mvc.Tests.Shared/PartialViewResultAssertions_Tests.cs index 16910e6..c58b556 100644 --- a/tests/FluentAssertions.Mvc.Tests.Shared/PartialViewResultAssertions_Tests.cs +++ b/tests/FluentAssertions.Mvc.Tests.Shared/PartialViewResultAssertions_Tests.cs @@ -1,10 +1,5 @@ using System; -#if NETCOREAPP1_0 -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.ViewFeatures; -#else using System.Web.Mvc; -#endif using NUnit.Framework; using FluentAssertions.Mvc.Tests.Helpers; @@ -28,28 +23,22 @@ public void WithDefaultViewName_GivenExpectedValue_ShouldPass() [Test] public void Model_GivenExpectedValue_ShouldPass() { -#if NETCOREAPP1_0 - var result = new TestController().PartialViewSimpleModel(); -#else ActionResult result = new PartialViewResult { ViewData = new ViewDataDictionary("hello") }; -#endif + result.Should().BePartialViewResult().Model.Should().Be("hello"); } [Test] public void Model_GivenUnexpectedValue_ShouldFail() { -#if NETCOREAPP1_0 - var result = new TestController().PartialViewSimpleModel(); -#else ActionResult result = new PartialViewResult { ViewData = new ViewDataDictionary("hello") }; -#endif + Action a = () => result.Should().BePartialViewResult().Model.Should().Be("xyx"); a.Should().Throw(); } @@ -57,28 +46,22 @@ public void Model_GivenUnexpectedValue_ShouldFail() [Test] public void ModelAs_GivenExpectedValue_ShouldPass() { -#if NETCOREAPP1_0 - var result = new TestController().PartialViewSimpleModel(); -#else ActionResult result = new PartialViewResult { ViewData = new ViewDataDictionary("hello") }; -#endif + result.Should().BePartialViewResult().ModelAs().Should().Be("hello"); } [Test] public void ModelAs_GivenUnexpectedValue_ShouldFail() { -#if NETCOREAPP1_0 - var result = new TestController().PartialViewSimpleModel(); -#else ActionResult result = new PartialViewResult { ViewData = new ViewDataDictionary("hello") }; -#endif + Action a = () => result.Should().BePartialViewResult().ModelAs().Should().Be("xyx"); a.Should().Throw(); } @@ -86,14 +69,11 @@ public void ModelAs_GivenUnexpectedValue_ShouldFail() [Test] public void ModelAs_GivenWrongType_ShouldFail() { -#if NETCOREAPP1_0 - var result = new TestController().PartialViewSimpleModel(); -#else ActionResult result = new PartialViewResult { ViewData = new ViewDataDictionary("hello") }; -#endif + Action a = () => result.Should().BePartialViewResult().ModelAs().Should().Be(2); a.Should().Throw(); } diff --git a/tests/FluentAssertions.Mvc.Tests.Shared/RedirectResultAssertions_Tests.cs b/tests/FluentAssertions.Mvc.Tests.Shared/RedirectResultAssertions_Tests.cs index 8c271e9..37b3e54 100644 --- a/tests/FluentAssertions.Mvc.Tests.Shared/RedirectResultAssertions_Tests.cs +++ b/tests/FluentAssertions.Mvc.Tests.Shared/RedirectResultAssertions_Tests.cs @@ -1,9 +1,5 @@ using System; -#if NETCOREAPP1_0 -using Microsoft.AspNetCore.Mvc; -#else using System.Web.Mvc; -#endif using NUnit.Framework; namespace FluentAssertions.Mvc.Tests diff --git a/tests/FluentAssertions.Mvc.Tests.Shared/RedirectToRoute_Tests.cs b/tests/FluentAssertions.Mvc.Tests.Shared/RedirectToRoute_Tests.cs index d018ba7..c8a33d9 100644 --- a/tests/FluentAssertions.Mvc.Tests.Shared/RedirectToRoute_Tests.cs +++ b/tests/FluentAssertions.Mvc.Tests.Shared/RedirectToRoute_Tests.cs @@ -1,11 +1,6 @@ using System; -#if NETCOREAPP1_0 -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Routing; -#else using System.Web.Mvc; using System.Web.Routing; -#endif using NUnit.Framework; namespace FluentAssertions.Mvc.Tests diff --git a/tests/FluentAssertions.Mvc.Tests.Shared/RouteDataAssertions_Tests.cs b/tests/FluentAssertions.Mvc.Tests.Shared/RouteDataAssertions_Tests.cs index 4bff4d3..3ece098 100644 --- a/tests/FluentAssertions.Mvc.Tests.Shared/RouteDataAssertions_Tests.cs +++ b/tests/FluentAssertions.Mvc.Tests.Shared/RouteDataAssertions_Tests.cs @@ -1,5 +1,4 @@ -#if !NETCOREAPP1_0 -using System; +using System; using System.Web.Mvc; using System.Web.Routing; using FluentAssertions.Mvc.Tests.Helpers; @@ -171,4 +170,3 @@ public void HaveDataToken_GivenUnexpectedArea_ShouldFail() } } } -#endif \ No newline at end of file diff --git a/tests/FluentAssertions.Mvc.Tests.Shared/RouteValueDictionary_Extensions_Tests.cs b/tests/FluentAssertions.Mvc.Tests.Shared/RouteValueDictionary_Extensions_Tests.cs index cd3019a..8a29e6d 100644 --- a/tests/FluentAssertions.Mvc.Tests.Shared/RouteValueDictionary_Extensions_Tests.cs +++ b/tests/FluentAssertions.Mvc.Tests.Shared/RouteValueDictionary_Extensions_Tests.cs @@ -1,9 +1,4 @@ -#if !NETCOREAPP1_0 -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using NUnit.Framework; +using NUnit.Framework; using System.Web.Mvc; using System.Web.Routing; @@ -100,4 +95,3 @@ public void GenerateUrl_GivenNotDefaultControllerAndActionValues_ShouldReturnExp } } -#endif \ No newline at end of file diff --git a/tests/FluentAssertions.Mvc.Tests.Shared/ViewResultAssertions_Tests.cs b/tests/FluentAssertions.Mvc.Tests.Shared/ViewResultAssertions_Tests.cs index 9e06cc4..475311c 100644 --- a/tests/FluentAssertions.Mvc.Tests.Shared/ViewResultAssertions_Tests.cs +++ b/tests/FluentAssertions.Mvc.Tests.Shared/ViewResultAssertions_Tests.cs @@ -1,18 +1,9 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using FluentAssertions.Mvc; using FluentAssertions.Mvc.Tests.Fakes; using FluentAssertions.Mvc.Tests.Helpers; using NUnit.Framework; -#if NETCOREAPP1_0 -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.ViewFeatures; -#else using System.Web.Mvc; -#endif namespace FluentAssertions.Mvc.Tests { @@ -21,7 +12,6 @@ public class ViewResultAssertions_Tests { private FakeController _controller = new FakeController(); -#if !NETCOREAPP1_0 [Test] public void WithMasterName_GivenExpectedValue_ShouldPass() { @@ -49,7 +39,6 @@ public void WithMasterName_GivenUnexpectedValue_ShouldFail() action.Should().Throw() .WithMessage(failureMessage); } -#endif [Test] public void WithViewName_GivenExpectedValue_ShouldPass() @@ -82,14 +71,10 @@ public void WithViewName_GivenUnexpectedValue_ShouldFail() [Test] public void WithTempData_GivenExpectedValue_ShouldPass() { -#if NETCOREAPP1_0 - var result = new TestController().ViewWithOneTempData(); -#else ActionResult result = new ViewResult { TempData = new TempDataDictionary { { "key1", "value1" } } }; -#endif result.Should().BeViewResult().WithTempData("key1", "value1"); } @@ -97,9 +82,6 @@ public void WithTempData_GivenExpectedValue_ShouldPass() [Test] public void WithTempData_GivenTwoExpectedValues_ShouldPass() { -#if NETCOREAPP1_0 - var result = new TestController().ViewWithTwoTempData(); -#else ActionResult result = new ViewResult { TempData = new TempDataDictionary @@ -108,7 +90,6 @@ public void WithTempData_GivenTwoExpectedValues_ShouldPass() { "key2", "value2" }, } }; -#endif result.Should().BeViewResult() .WithTempData("key1", "value1") @@ -118,14 +99,10 @@ public void WithTempData_GivenTwoExpectedValues_ShouldPass() [Test] public void WithTempData_GivenUnexpectedValue_ShouldFail() { -#if NETCOREAPP1_0 - var result = new TestController().ViewWithOneTempData(); -#else ActionResult result = new ViewResult { TempData = new TempDataDictionary { { "key1", "value1" } } }; -#endif Action a = () => result.Should().BeViewResult().WithTempData("key1", "xyz"); a.Should().Throw(); @@ -134,14 +111,10 @@ public void WithTempData_GivenUnexpectedValue_ShouldFail() [Test] public void WithTempData_GivenUnexpectedKey_ShouldFail() { -#if NETCOREAPP1_0 - var result = new TestController().ViewWithOneTempData(); -#else ActionResult result = new ViewResult { TempData = new TempDataDictionary { { "key1", "value1" } } }; -#endif Action a = () => result.Should().BeViewResult().WithTempData("xyz", "value1"); a.Should().Throw(); @@ -150,14 +123,10 @@ public void WithTempData_GivenUnexpectedKey_ShouldFail() [Test] public void WithViewData_GivenExpectedValue_ShouldPass() { -#if NETCOREAPP1_0 - var result = new TestController().ViewWithOneViewData(); -#else ActionResult result = new ViewResult { ViewData = new ViewDataDictionary { { "key1", "value1" } } }; -#endif result.Should().BeViewResult().WithViewData("key1", "value1"); } @@ -165,9 +134,6 @@ public void WithViewData_GivenExpectedValue_ShouldPass() [Test] public void WithViewData_GivenTwoExpectedValues_ShouldPass() { -#if NETCOREAPP1_0 - var result = new TestController().ViewWithTwoViewData(); -#else ActionResult result = new ViewResult { ViewData = new ViewDataDictionary @@ -176,7 +142,6 @@ public void WithViewData_GivenTwoExpectedValues_ShouldPass() { "key2", "value2" }, } }; -#endif result.Should().BeViewResult() .WithViewData("key1", "value1") @@ -191,14 +156,10 @@ public void WithViewData_GivenUnexpectedValue_ShouldFail() var expectedValue = "abc"; var failureMessage = FailureMessageHelper.Format(FailureMessages.ViewResultBase_ViewData_HaveValue, key, expectedValue, actualValue); -#if NETCOREAPP1_0 - var result = new TestController().ViewWithOneViewData(); -#else ActionResult result = new ViewResult { ViewData = new ViewDataDictionary { { key, actualValue } } }; -#endif Action a = () => result.Should().BeViewResult().WithViewData(key, expectedValue); @@ -212,14 +173,10 @@ public void WithViewData_GivenUnexpectedKey_ShouldFail() var actualKey = "key1"; var expectedKey = "xyz"; -#if NETCOREAPP1_0 - var result = new TestController().ViewWithTwoViewData(); -#else ActionResult result = new ViewResult { ViewData = new ViewDataDictionary { { actualKey, "value1" } } }; -#endif var failureMessage = FailureMessageHelper.Format(FailureMessages.ViewResultBase_ViewData_ContainsKey, expectedKey, actualKey); Action a = () => result.Should().BeViewResult().WithViewData(expectedKey, "value1"); @@ -231,14 +188,10 @@ public void WithViewData_GivenUnexpectedKey_ShouldFail() [Test] public void Model_GivenExpectedValue_ShouldPass() { -#if NETCOREAPP1_0 - var result = new TestController().ViewSimpleModel(); -#else ActionResult result = new ViewResult { ViewData = new ViewDataDictionary("hello") }; -#endif result.Should().BeViewResult().Model.Should().Be("hello"); } @@ -246,14 +199,10 @@ public void Model_GivenExpectedValue_ShouldPass() [Test] public void Model_GivenUnexpectedValue_ShouldFail() { -#if NETCOREAPP1_0 - var result = new TestController().ViewSimpleModel(); -#else ActionResult result = new ViewResult { ViewData = new ViewDataDictionary("hello") }; -#endif Action a = () => result.Should().BeViewResult().Model.Should().Be("xyx"); a.Should().Throw(); @@ -262,14 +211,10 @@ public void Model_GivenUnexpectedValue_ShouldFail() [Test] public void ModelAs_GivenExpectedValue_ShouldPass() { -#if NETCOREAPP1_0 - var result = new TestController().ViewSimpleModel(); -#else ActionResult result = new ViewResult { ViewData = new ViewDataDictionary("hello") }; -#endif result.Should().BeViewResult().ModelAs().Should().Be("hello"); } @@ -277,14 +222,10 @@ public void ModelAs_GivenExpectedValue_ShouldPass() [Test] public void ModelAs_GivenUnexpectedValue_ShouldFail() { -#if NETCOREAPP1_0 - var result = new TestController().ViewSimpleModel(); -#else ActionResult result = new ViewResult { ViewData = new ViewDataDictionary("hello") }; -#endif Action a = () => result.Should().BeViewResult().ModelAs().Should().Be("xyx"); a.Should().Throw(); @@ -293,14 +234,10 @@ public void ModelAs_GivenUnexpectedValue_ShouldFail() [Test] public void ModelAs_GivenWrongType_ShouldFail() { -#if NETCOREAPP1_0 - var result = new TestController().ViewSimpleModel(); -#else ActionResult result = new ViewResult { ViewData = new ViewDataDictionary("hello") }; -#endif Action a = () => result.Should().BeViewResult().ModelAs().Should().Be(2); a.Should().Throw();