diff options
author | Alexander Köplinger <alex.koeplinger@outlook.com> | 2017-10-19 13:38:33 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-19 13:38:33 +0300 |
commit | 6caf00b09ca862bdd88252cc77d827000f2d58ba (patch) | |
tree | 2f467e59b17444b106871e227e0680aa4c50f8ae /mcs/class/System.Web.Routing | |
parent | cfedbd7aa2fdb93e42e88cc488bd436942ef8e3e (diff) |
[bcl] Remove AssertExtensions helper classes (#5828)
* [bcl] Remove AssertExtensions helper classes
Since we're on nunitlite now we can use the proper `Assert.Throws<>()`
instead and remove the helper class (which we actually duplicated!)
Diffstat (limited to 'mcs/class/System.Web.Routing')
5 files changed, 20 insertions, 97 deletions
diff --git a/mcs/class/System.Web.Routing/System.Web.Routing_test.dll.sources b/mcs/class/System.Web.Routing/System.Web.Routing_test.dll.sources index 43a05efd883..33a61b936e6 100644 --- a/mcs/class/System.Web.Routing/System.Web.Routing_test.dll.sources +++ b/mcs/class/System.Web.Routing/System.Web.Routing_test.dll.sources @@ -1,4 +1,3 @@ -System.Web.Routing/AssertExtensions.cs System.Web.Routing/FakeHttpWorkerRequest.cs System.Web.Routing/HttpMethodConstraintTest.cs System.Web.Routing/KnownResponseHeader.cs diff --git a/mcs/class/System.Web.Routing/Test/System.Web.Routing/AssertExtensions.cs b/mcs/class/System.Web.Routing/Test/System.Web.Routing/AssertExtensions.cs deleted file mode 100644 index b5441652224..00000000000 --- a/mcs/class/System.Web.Routing/Test/System.Web.Routing/AssertExtensions.cs +++ /dev/null @@ -1,76 +0,0 @@ -// -// AssertExtensions.cs -// -// Author: -// Marek Habersack <mhabersack@novell.com> -// -// Copyright (C) 2009 Novell Inc. http://novell.com -// - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// -using System; -using System.Web; -using System.Web.Routing; -using NUnit.Framework; - -namespace MonoTests.System.Web.Routing -{ - public delegate void AssertThrowsDelegate (); - - public static class AssertExtensions - { - public static void Throws <EX> (AssertThrowsDelegate code) - { - Throws (typeof (EX), code); - } - - public static void Throws <EX> (AssertThrowsDelegate code, string message) - { - Throws (typeof (EX), code, message); - } - - public static void Throws (Type exceptionType, AssertThrowsDelegate code) - { - Throws (exceptionType, code, String.Empty); - } - - public static void Throws (Type exceptionType, AssertThrowsDelegate code, string message) - { - if (code == null) - throw new ArgumentNullException ("code"); - if (exceptionType == null) - throw new ArgumentNullException ("exceptionType"); - - try { - code (); - } catch (Exception ex) { - if (ex.GetType () != exceptionType) - Assert.Fail (message + " (got exception of type '" + ex.GetType () + "')"); - - // good! - return; - } - - Assert.Fail (message); - } - } -} diff --git a/mcs/class/System.Web.Routing/Test/System.Web.Routing/RequestContext.cs b/mcs/class/System.Web.Routing/Test/System.Web.Routing/RequestContext.cs index 5d2aeceb855..d63053bb1d2 100644 --- a/mcs/class/System.Web.Routing/Test/System.Web.Routing/RequestContext.cs +++ b/mcs/class/System.Web.Routing/Test/System.Web.Routing/RequestContext.cs @@ -53,12 +53,12 @@ namespace MonoTests.System.Web.Routing { RequestContext rc; - AssertExtensions.Throws<ArgumentNullException> (() => { + Assert.Throws<ArgumentNullException> (() => { rc = new RequestContext (null, new RouteData ()); }, "#A1"); var ctx = new HttpContextWrapper (new HttpContext (new HttpRequest ("filename", "http://localhost/filename", String.Empty), new HttpResponse (new StringWriter ()))); - AssertExtensions.Throws<ArgumentNullException> (() => { + Assert.Throws<ArgumentNullException> (() => { rc = new RequestContext (ctx, null); }, "#A2"); } diff --git a/mcs/class/System.Web.Routing/Test/System.Web.Routing/RouteCollectionTest.cs b/mcs/class/System.Web.Routing/Test/System.Web.Routing/RouteCollectionTest.cs index c2d2d51a28d..a4145730a33 100644 --- a/mcs/class/System.Web.Routing/Test/System.Web.Routing/RouteCollectionTest.cs +++ b/mcs/class/System.Web.Routing/Test/System.Web.Routing/RouteCollectionTest.cs @@ -644,7 +644,7 @@ namespace MonoTests.System.Web.Routing { var c = new RouteCollection (); - AssertExtensions.Throws<ArgumentNullException> (() => { + Assert.Throws<ArgumentNullException> (() => { c.Ignore (null); }, "#A1"); @@ -666,7 +666,7 @@ namespace MonoTests.System.Web.Routing { var c = new RouteCollection (); - AssertExtensions.Throws<ArgumentNullException> (() => { + Assert.Throws<ArgumentNullException> (() => { c.Ignore (null, new { allaspx = @".*\.aspx(/.*)?" }); }, "#A1"); @@ -686,7 +686,7 @@ namespace MonoTests.System.Web.Routing c = new RouteCollection (); c.Ignore ("{*allaspx}", "something invalid"); - AssertExtensions.Throws<InvalidOperationException> (() => { + Assert.Throws<InvalidOperationException> (() => { rd = c.GetRouteData (hc); }, "#A2"); } @@ -706,7 +706,7 @@ namespace MonoTests.System.Web.Routing Assert.AreEqual (typeof (PageRouteHandler), rd.RouteHandler.GetType (), "#A1-3"); c = new RouteCollection (); - AssertExtensions.Throws<ArgumentNullException> (() => { + Assert.Throws<ArgumentNullException> (() => { c.MapPageRoute ("RouteName", null, "~/some-url"); }, "#A2"); @@ -718,7 +718,7 @@ namespace MonoTests.System.Web.Routing c = new RouteCollection (); // thrown by PageRouteHandler's constructor - AssertExtensions.Throws<ArgumentException> (() => { + Assert.Throws<ArgumentException> (() => { c.MapPageRoute ("RouteName", "~/some-url", null); }, "#A3"); } @@ -739,7 +739,7 @@ namespace MonoTests.System.Web.Routing Assert.IsTrue (((PageRouteHandler) rd.RouteHandler).CheckPhysicalUrlAccess, "#A1-4"); c = new RouteCollection (); - AssertExtensions.Throws<ArgumentNullException> (() => { + Assert.Throws<ArgumentNullException> (() => { c.MapPageRoute ("RouteName", null, "~/some-url", true); }, "#A2"); @@ -751,7 +751,7 @@ namespace MonoTests.System.Web.Routing c = new RouteCollection (); // thrown by PageRouteHandler's constructor - AssertExtensions.Throws<ArgumentException> (() => { + Assert.Throws<ArgumentException> (() => { c.MapPageRoute ("RouteName", "~/some-url", null, true); }, "#A3"); @@ -781,7 +781,7 @@ namespace MonoTests.System.Web.Routing Assert.IsTrue (((PageRouteHandler) rd.RouteHandler).CheckPhysicalUrlAccess, "#A1-4"); c = new RouteCollection (); - AssertExtensions.Throws<ArgumentNullException> (() => { + Assert.Throws<ArgumentNullException> (() => { c.MapPageRoute ("RouteName", null, "~/some-url", true, defaults); }, "#A2"); @@ -793,7 +793,7 @@ namespace MonoTests.System.Web.Routing c = new RouteCollection (); // thrown by PageRouteHandler's constructor - AssertExtensions.Throws<ArgumentException> (() => { + Assert.Throws<ArgumentException> (() => { c.MapPageRoute ("RouteName", "~/some-url", null, true, defaults); }, "#A3"); @@ -832,7 +832,7 @@ namespace MonoTests.System.Web.Routing Assert.IsTrue (((PageRouteHandler) rd.RouteHandler).CheckPhysicalUrlAccess, "#A1-4"); c = new RouteCollection (); - AssertExtensions.Throws<ArgumentNullException> (() => { + Assert.Throws<ArgumentNullException> (() => { c.MapPageRoute ("RouteName", null, "~/some-url", true, defaults, constraints); }, "#A2"); @@ -844,7 +844,7 @@ namespace MonoTests.System.Web.Routing c = new RouteCollection (); // thrown by PageRouteHandler's constructor - AssertExtensions.Throws<ArgumentException> (() => { + Assert.Throws<ArgumentException> (() => { c.MapPageRoute ("RouteName", "~/some-url", null, true, defaults, constraints); }, "#A3"); @@ -884,7 +884,7 @@ namespace MonoTests.System.Web.Routing Assert.IsTrue (((PageRouteHandler) rd.RouteHandler).CheckPhysicalUrlAccess, "#A1-4"); c = new RouteCollection (); - AssertExtensions.Throws<ArgumentNullException> (() => { + Assert.Throws<ArgumentNullException> (() => { c.MapPageRoute ("RouteName", null, "~/some-url", true, defaults, constraints, dataTokens); }, "#A2"); @@ -896,7 +896,7 @@ namespace MonoTests.System.Web.Routing c = new RouteCollection (); // thrown by PageRouteHandler's constructor - AssertExtensions.Throws<ArgumentException> (() => { + Assert.Throws<ArgumentException> (() => { c.MapPageRoute ("RouteName", "~/some-url", null, true, defaults, constraints, dataTokens); }, "#A3"); diff --git a/mcs/class/System.Web.Routing/Test/System.Web.Routing/RouteTest.cs b/mcs/class/System.Web.Routing/Test/System.Web.Routing/RouteTest.cs index c9fd18a29cf..4bdd51c5dd6 100644 --- a/mcs/class/System.Web.Routing/Test/System.Web.Routing/RouteTest.cs +++ b/mcs/class/System.Web.Routing/Test/System.Web.Routing/RouteTest.cs @@ -113,7 +113,7 @@ namespace MonoTests.System.Web.Routing Route r; foreach (TestUrl tu in __invalidUrls) { - AssertExtensions.Throws (tu.ExpectedExceptionType, () => r = new Route (tu.Url, null), tu.Label); + Assert.Throws (tu.ExpectedExceptionType, () => r = new Route (tu.Url, null), tu.Label); } } @@ -1763,18 +1763,18 @@ namespace MonoTests.System.Web.Routing Assert.IsFalse (route.DoProcessConstraint (null, "regex", "parameter", new RouteValueDictionary (), RouteDirection.IncomingRequest), "#1"); // constraint is null - AssertExtensions.Throws <InvalidOperationException> ( + Assert.Throws <InvalidOperationException> ( () => route.DoProcessConstraint (null, null, "parameter", new RouteValueDictionary (), RouteDirection.IncomingRequest), "#2" ); // constraint is neither a string or an IRouteConstraint instance - AssertExtensions.Throws <InvalidOperationException> ( + Assert.Throws <InvalidOperationException> ( () => route.DoProcessConstraint (null, 1, "parameter", new RouteValueDictionary (), RouteDirection.IncomingRequest), "#3" ); - AssertExtensions.Throws <ArgumentNullException> ( + Assert.Throws <ArgumentNullException> ( () => route.DoProcessConstraint (null, "regex", null, new RouteValueDictionary (), RouteDirection.IncomingRequest), "#4" ); @@ -1782,7 +1782,7 @@ namespace MonoTests.System.Web.Routing Assert.IsFalse (route.DoProcessConstraint (null, "regex", String.Empty, new RouteValueDictionary (), RouteDirection.IncomingRequest), "#5"); // This is a .NET programming error, so not sure if we should test for this... - AssertExtensions.Throws <NullReferenceException> ( + Assert.Throws <NullReferenceException> ( () => route.DoProcessConstraint (null, "regex", "parameter", null, RouteDirection.IncomingRequest), "#6" ); |