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.DynamicData | |
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.DynamicData')
10 files changed, 78 insertions, 161 deletions
diff --git a/mcs/class/System.Web.DynamicData/System.Web.DynamicData_test.dll.sources b/mcs/class/System.Web.DynamicData/System.Web.DynamicData_test.dll.sources index 67e3e1a6408..6da1d6234b6 100644 --- a/mcs/class/System.Web.DynamicData/System.Web.DynamicData_test.dll.sources +++ b/mcs/class/System.Web.DynamicData/System.Web.DynamicData_test.dll.sources @@ -37,7 +37,6 @@ Assembly/AssemblyInfo.cs Common/AFieldTemplate.cs -Common/AssertExtensions.cs Common/AssociatedBar.cs Common/AssociatedFoo.cs Common/BazColumnAttributes.cs diff --git a/mcs/class/System.Web.DynamicData/Test/Common/AssertExtensions.cs b/mcs/class/System.Web.DynamicData/Test/Common/AssertExtensions.cs deleted file mode 100644 index 41e340bfd35..00000000000 --- a/mcs/class/System.Web.DynamicData/Test/Common/AssertExtensions.cs +++ /dev/null @@ -1,82 +0,0 @@ -using System; -using System.Collections.Generic; - -using NUnit.Framework; - -namespace MonoTests.Common -{ - delegate void AssertThrowsDelegate(); - - static class AssertExtensions - { - public static void AreEqual (byte[] expected, byte[] data, string message) - { - if (expected == null) { - if (data == null) - return; - Assert.Fail ("{0}{1}Expected: null{1}Got: byte array with {2} elements and of rank {3}{1}", - message, Environment.NewLine, data.Length, data.Rank); - } - - if (data == null) - Assert.Fail ("{0}{1}Expected: byte array with {2} elements and rank {3}{1}Got: null{1}", - message, Environment.NewLine, expected.Length, expected.Rank); - - if (expected.Rank > 1) - Assert.Fail ("Only single-dimensional arrays are supported."); - - if (expected.Rank != data.Rank || expected.Length != data.Length) - Assert.Fail ("{0}{1}Expected: byte array with {2} elements and rank {3}{1}Got: byte array with {4} elements and rank {5}{1}", - message, Environment.NewLine, expected.Length, expected.Rank, data.Length, data.Rank); - - int max = expected.Length; - for (int i = 0; i < max; i++) { - if (expected[i] != data[i]) - Assert.Fail ("{0}{1}Arrays differ at index {2}.{1}Expected 0x{3:X} got 0x{4:X}{1}", - message, Environment.NewLine, i, expected[i], data[i]); - } - } - - public static void Throws<ET> (AssertThrowsDelegate code, string message) - { - Throws(typeof(ET), code, message); - } - - public static void Throws(Type exceptionType, AssertThrowsDelegate code, string message) - { - if (code == null) - Assert.Fail("No code provided for the test."); - - Exception exception = null; - try - { - code(); - } - catch (Exception ex) - { - exception = ex; - } - - if (exceptionType == null) - { - if (exception == null) - Assert.Fail("{0}{1}Expected: any exception thrown{1}But was: no exception thrown{1}", - message, Environment.NewLine); - return; - } - - if (exception == null || exception.GetType() != exceptionType) - Assert.Fail("{0}{1}Expected: {2}{1}But was: {3}{1}{4}{1}", - message, - Environment.NewLine, - exceptionType, - exception == null ? "no exception" : exception.GetType().ToString(), - exception == null ? "no exception" : exception.ToString()); - } - - public static void Throws(AssertThrowsDelegate code, string message) - { - Throws(null, code, message); - } - } -} diff --git a/mcs/class/System.Web.DynamicData/Test/System.Web.DynamicData/DynamicControlTest.cs b/mcs/class/System.Web.DynamicData/Test/System.Web.DynamicData/DynamicControlTest.cs index 5656080a73d..b940a2dbfe7 100644 --- a/mcs/class/System.Web.DynamicData/Test/System.Web.DynamicData/DynamicControlTest.cs +++ b/mcs/class/System.Web.DynamicData/Test/System.Web.DynamicData/DynamicControlTest.cs @@ -362,7 +362,7 @@ namespace MonoTests.System.Web.DynamicData // at System.Web.DynamicData.DynamicControl.ResolveColumn() // at System.Web.DynamicData.DynamicControl.OnInit(EventArgs e) - AssertExtensions.Throws<InvalidOperationException> (() => { + Assert.Throws<InvalidOperationException> (() => { var c = lc.FindChild<DynamicControl> ("FirstName"); }, "#A1"); } @@ -389,7 +389,7 @@ namespace MonoTests.System.Web.DynamicData // at System.Web.DynamicData.DynamicControl.ResolveColumn() // at System.Web.DynamicData.DynamicControl.OnInit(EventArgs e) - AssertExtensions.Throws<InvalidOperationException> (() => { + Assert.Throws<InvalidOperationException> (() => { var dc = lc.FindChild<DynamicControl> ("FirstName"); }, "#A1"); } @@ -641,7 +641,7 @@ namespace MonoTests.System.Web.DynamicData Assert.AreEqual ("value", dc.GetAttribute ("MyAttribute"), "#B1"); // Nice... - AssertExtensions.Throws<KeyNotFoundException> (() => { + Assert.Throws<KeyNotFoundException> (() => { dc.GetAttribute ("NoSuchAttribute"); }, "#C1"); } diff --git a/mcs/class/System.Web.DynamicData/Test/System.Web.DynamicData/DynamicDataExtensionsTest.cs b/mcs/class/System.Web.DynamicData/Test/System.Web.DynamicData/DynamicDataExtensionsTest.cs index 1f57541ed63..3367d54a22a 100644 --- a/mcs/class/System.Web.DynamicData/Test/System.Web.DynamicData/DynamicDataExtensionsTest.cs +++ b/mcs/class/System.Web.DynamicData/Test/System.Web.DynamicData/DynamicDataExtensionsTest.cs @@ -128,7 +128,7 @@ namespace MonoTests.System.Web.DynamicData { FieldFormattingOptions fld = null; - AssertExtensions.Throws<NullReferenceException> (() => { + Assert.Throws<NullReferenceException> (() => { fld.ConvertEditedValue (null); }, "#A1"); diff --git a/mcs/class/System.Web.DynamicData/Test/System.Web.DynamicData/DynamicDataRouteHandlerTest.cs b/mcs/class/System.Web.DynamicData/Test/System.Web.DynamicData/DynamicDataRouteHandlerTest.cs index b44c8bd9327..b03d5d40321 100644 --- a/mcs/class/System.Web.DynamicData/Test/System.Web.DynamicData/DynamicDataRouteHandlerTest.cs +++ b/mcs/class/System.Web.DynamicData/Test/System.Web.DynamicData/DynamicDataRouteHandlerTest.cs @@ -87,17 +87,17 @@ namespace MonoTests.System.Web.DynamicData var handler = route.RouteHandler = new DynamicDataRouteHandler (); // No null check is made, of course - throws from some internal method - AssertExtensions.Throws<NullReferenceException> (() => { + Assert.Throws<NullReferenceException> (() => { handler.CreateHandler (null, t, PageAction.Details); }, "#A1"); // No null check again - this time throws from GetCustomPageVirtualPath - AssertExtensions.Throws<NullReferenceException> (() => { + Assert.Throws<NullReferenceException> (() => { handler.CreateHandler (route, null, PageAction.Details); }, "#A2"); // And once again, no null check and thrown from GetCustomPageVirtualPath as well - AssertExtensions.Throws<NullReferenceException> (() => { + Assert.Throws<NullReferenceException> (() => { handler.CreateHandler (route, t, null); }, "#A3"); } @@ -152,13 +152,13 @@ namespace MonoTests.System.Web.DynamicData Assert.IsNotNull (handler, "#A2"); // Lack of null check (for table) - AssertExtensions.Throws<NullReferenceException> (() => { + Assert.Throws<NullReferenceException> (() => { handler.DoGetCustomPageVirtualPath (null, null); }, "#A2-1"); // Another missing null check (this time for Model)... Are null checks // out of fashion? - AssertExtensions.Throws<NullReferenceException> (() => { + Assert.Throws<NullReferenceException> (() => { handler.DoGetCustomPageVirtualPath (t, String.Empty); }, "#A2-2"); @@ -193,7 +193,7 @@ namespace MonoTests.System.Web.DynamicData [Test] public void GetRequestContext () { - AssertExtensions.Throws<ArgumentNullException> (() => { + Assert.Throws<ArgumentNullException> (() => { DynamicDataRouteHandler.GetRequestContext (null); }, "#A1"); @@ -220,7 +220,7 @@ namespace MonoTests.System.Web.DynamicData Assert.IsNotNull (t, "#A1"); // Surprise! A null check is present! - AssertExtensions.Throws<ArgumentNullException> (() => { + Assert.Throws<ArgumentNullException> (() => { DynamicDataRouteHandler.GetRequestMetaTable (null); }, "#A2"); @@ -248,13 +248,13 @@ namespace MonoTests.System.Web.DynamicData Assert.IsNotNull (handler, "#A2"); // Lack of null check (for table) - AssertExtensions.Throws<NullReferenceException> (() => { + Assert.Throws<NullReferenceException> (() => { handler.DoGetScaffoldPageVirtualPath (null, null); }, "#A2-1"); // Another missing null check (this time for Model)... Are null checks // out of fashion? - AssertExtensions.Throws<NullReferenceException> (() => { + Assert.Throws<NullReferenceException> (() => { handler.DoGetScaffoldPageVirtualPath (t, String.Empty); }, "#A2-2"); @@ -343,7 +343,7 @@ namespace MonoTests.System.Web.DynamicData Assert.IsNotNull (t, "#A1"); // And following the tradition... [drum roll] - NO NULL CHECK! - AssertExtensions.Throws<NullReferenceException> (() => { + Assert.Throws<NullReferenceException> (() => { DynamicDataRouteHandler.SetRequestMetaTable (null, t); }, "#A2"); diff --git a/mcs/class/System.Web.DynamicData/Test/System.Web.DynamicData/DynamicDataRouteTest.cs b/mcs/class/System.Web.DynamicData/Test/System.Web.DynamicData/DynamicDataRouteTest.cs index 1151fb86612..91cd764338c 100644 --- a/mcs/class/System.Web.DynamicData/Test/System.Web.DynamicData/DynamicDataRouteTest.cs +++ b/mcs/class/System.Web.DynamicData/Test/System.Web.DynamicData/DynamicDataRouteTest.cs @@ -298,7 +298,7 @@ namespace MonoTests.System.Web.DynamicData var rd = new RouteData (); var hc = new HttpContextWrapper (HttpContext.Current); - AssertExtensions.Throws <ArgumentException> (() => { + Assert.Throws <ArgumentException> (() => { ddr.GetVirtualPath (new RequestContext (hc, rd), null); }, "#A1"); } @@ -444,7 +444,7 @@ namespace MonoTests.System.Web.DynamicData var rd = new RouteData (); var hc = new HttpContextWrapper (HttpContext.Current); - AssertExtensions.Throws<ArgumentException> (() => { + Assert.Throws<ArgumentException> (() => { ddr.GetVirtualPath (new RequestContext (hc, rd), null); }, "#A1"); } diff --git a/mcs/class/System.Web.DynamicData/Test/System.Web.DynamicData/FieldTemplateFactoryTest.cs b/mcs/class/System.Web.DynamicData/Test/System.Web.DynamicData/FieldTemplateFactoryTest.cs index 8362f3b6a96..978a6e1b772 100644 --- a/mcs/class/System.Web.DynamicData/Test/System.Web.DynamicData/FieldTemplateFactoryTest.cs +++ b/mcs/class/System.Web.DynamicData/Test/System.Web.DynamicData/FieldTemplateFactoryTest.cs @@ -135,11 +135,11 @@ namespace MonoTests.System.Web.DynamicData MetaColumn mc = t.GetColumn ("Column1"); var ftf = new FieldTemplateFactory (); - AssertExtensions.Throws<ArgumentNullException> (() => { + Assert.Throws<ArgumentNullException> (() => { ftf.BuildVirtualPath (null, mc, DataBoundControlMode.ReadOnly); }, "#A1"); - AssertExtensions.Throws<ArgumentNullException> (() => { + Assert.Throws<ArgumentNullException> (() => { ftf.BuildVirtualPath (String.Empty, mc, DataBoundControlMode.ReadOnly); }, "#A2"); @@ -179,7 +179,7 @@ namespace MonoTests.System.Web.DynamicData var ftf = new FieldTemplateFactory (); // And here we go again... - AssertExtensions.Throws<NullReferenceException> (() => { + Assert.Throws<NullReferenceException> (() => { ftf.CreateFieldTemplate (null, DataBoundControlMode.ReadOnly, "Integer.ascx"); }, "#A1"); @@ -187,17 +187,17 @@ namespace MonoTests.System.Web.DynamicData // Not going to emulate those on Mono. There are limits... // ...and again - AssertExtensions.Throws<NullReferenceException> (() => { + Assert.Throws<NullReferenceException> (() => { ftf.CreateFieldTemplate (mc, DataBoundControlMode.ReadOnly, null); }, "#A2"); // ...and again - AssertExtensions.Throws<NullReferenceException> (() => { + Assert.Throws<NullReferenceException> (() => { ftf.CreateFieldTemplate (mc, DataBoundControlMode.ReadOnly, String.Empty); }, "#A3"); // ...and again - AssertExtensions.Throws<NullReferenceException> (() => { + Assert.Throws<NullReferenceException> (() => { ftf.CreateFieldTemplate (mc, DataBoundControlMode.ReadOnly, "NoSuchTemplate"); }, "#A4"); #endif @@ -254,7 +254,7 @@ namespace MonoTests.System.Web.DynamicData Assert.AreEqual (ftf.TemplateFolderVirtualPath + "MyCustomUIHintTemplate_Text.ascx", ftuc.AppRelativeVirtualPath, "#E2-2"); mc = t.GetColumn ("FavoriteColor"); - AssertExtensions.Throws<HttpException> (() => { + Assert.Throws<HttpException> (() => { template = ftf.CreateFieldTemplate (mc, DataBoundControlMode.ReadOnly, "PlainControlTemplate"); }, "#F1"); @@ -280,23 +280,23 @@ namespace MonoTests.System.Web.DynamicData var ftf = new FieldTemplateFactory (); // And here we go again... - AssertExtensions.Throws<NullReferenceException> (() => { + Assert.Throws<NullReferenceException> (() => { ftf.GetFieldTemplateVirtualPath (null, DataBoundControlMode.ReadOnly, "Integer.ascx"); }, "#A1"); #if TARGET_DOTNET // ...and again - AssertExtensions.Throws<NullReferenceException> (() => { + Assert.Throws<NullReferenceException> (() => { ftf.GetFieldTemplateVirtualPath (mc, DataBoundControlMode.ReadOnly, null); }, "#A2"); // ...and again - AssertExtensions.Throws<NullReferenceException> (() => { + Assert.Throws<NullReferenceException> (() => { ftf.GetFieldTemplateVirtualPath (mc, DataBoundControlMode.ReadOnly, String.Empty); }, "#A3"); // ...and again - AssertExtensions.Throws<NullReferenceException> (() => { + Assert.Throws<NullReferenceException> (() => { ftf.GetFieldTemplateVirtualPath (mc, DataBoundControlMode.ReadOnly, "NoSuchTemplate"); }, "#A4"); #endif @@ -601,7 +601,7 @@ namespace MonoTests.System.Web.DynamicData ftf.Initialize (m); // Ugh... - AssertExtensions.Throws<NullReferenceException> (() => { + Assert.Throws<NullReferenceException> (() => { ftf.GetFieldTemplateVirtualPath (null, DataBoundControlMode.ReadOnly, "Integer.ascx"); }, "#A1"); @@ -634,11 +634,11 @@ namespace MonoTests.System.Web.DynamicData // Custom type // It appears that DataTypeAttribute's custom type name is passed to BuildVirtualPath - AssertExtensions.Throws<InvalidOperationException> (() => { + Assert.Throws<InvalidOperationException> (() => { string path = ftf.GetFieldTemplateVirtualPath (mc, DataBoundControlMode.ReadOnly, null); }, "#A1"); - AssertExtensions.Throws<InvalidOperationException> (() => { + Assert.Throws<InvalidOperationException> (() => { string path = ftf.GetFieldTemplateVirtualPath (mc, DataBoundControlMode.ReadOnly, "NoSuchTemplate"); }, "#A1-1"); Assert.AreEqual (ftf.TemplateFolderVirtualPath + "Boolean.ascx", ftf.GetFieldTemplateVirtualPath (mc, DataBoundControlMode.ReadOnly, "Boolean"), "#A1-2"); @@ -649,11 +649,11 @@ namespace MonoTests.System.Web.DynamicData AssertHelper.Greater (mc.UIHint.Length, 0, "#A2-1"); // Proves that UIHint on the column is not used, just the uiHint argument - AssertExtensions.Throws<InvalidOperationException> (() => { + Assert.Throws<InvalidOperationException> (() => { string path = ftf.GetFieldTemplateVirtualPath (mc, DataBoundControlMode.ReadOnly, null); }, "#A2-2"); - AssertExtensions.Throws<InvalidOperationException> (() => { + Assert.Throws<InvalidOperationException> (() => { string path = ftf.GetFieldTemplateVirtualPath (mc, DataBoundControlMode.ReadOnly, "NoSuchTemplate"); }, "#A2-3"); @@ -913,7 +913,7 @@ namespace MonoTests.System.Web.DynamicData var ftf = new FieldTemplateFactory (); ftf.Initialize (m); - AssertExtensions.Throws<NullReferenceException> (() => { + Assert.Throws<NullReferenceException> (() => { ftf.PreprocessMode (null, DataBoundControlMode.ReadOnly); }, "#A1"); @@ -1007,7 +1007,7 @@ namespace MonoTests.System.Web.DynamicData ftf.TemplateFolderVirtualPath = String.Empty; // Thrown from some internal method - no checks _again_ - AssertExtensions.Throws<ArgumentNullException> (() => { + Assert.Throws<ArgumentNullException> (() => { string path = ftf.TemplateFolderVirtualPath; }, "#A8"); @@ -1041,7 +1041,7 @@ namespace MonoTests.System.Web.DynamicData ftf.Initialize (m); ftf.TemplateFolderVirtualPath = String.Empty; - AssertExtensions.Throws<ArgumentNullException> (() => { + Assert.Throws<ArgumentNullException> (() => { string path = ftf.TemplateFolderVirtualPath; }, "#G1"); } diff --git a/mcs/class/System.Web.DynamicData/Test/System.Web.DynamicData/FieldTemplateUserControlTest.cs b/mcs/class/System.Web.DynamicData/Test/System.Web.DynamicData/FieldTemplateUserControlTest.cs index 423237d1ec0..ab09cd20c21 100644 --- a/mcs/class/System.Web.DynamicData/Test/System.Web.DynamicData/FieldTemplateUserControlTest.cs +++ b/mcs/class/System.Web.DynamicData/Test/System.Web.DynamicData/FieldTemplateUserControlTest.cs @@ -146,12 +146,12 @@ namespace MonoTests.System.Web.DynamicData field.Page = p; ((IFieldTemplate) field).SetHost (dc); - AssertExtensions.Throws<Exception> (() => { + Assert.Throws<Exception> (() => { var f = field.ChildrenColumn; }, "#C1"); // The FirstName column is not a children one - AssertExtensions.Throws<Exception> (() => { + Assert.Throws<Exception> (() => { field.GetChildrenPath (); }, "#C2"); Assert.IsNotNull (field.Column, "#C3"); @@ -181,10 +181,10 @@ namespace MonoTests.System.Web.DynamicData //Assert.IsNull (field.FieldValueString, "#C7"); // The FirstName column is not a foreign key one - AssertExtensions.Throws<Exception> (() => { + Assert.Throws<Exception> (() => { var f = field.ForeignKeyColumn; }, "#C8"); - AssertExtensions.Throws<Exception> (() => { + Assert.Throws<Exception> (() => { var f = field.GetForeignKeyPath (); }, "#C9"); Assert.IsNotNull (field.Host, "#C10"); diff --git a/mcs/class/System.Web.DynamicData/Test/System.Web.DynamicData/MetaModelTest.cs b/mcs/class/System.Web.DynamicData/Test/System.Web.DynamicData/MetaModelTest.cs index ed33152de0d..281efe05b26 100644 --- a/mcs/class/System.Web.DynamicData/Test/System.Web.DynamicData/MetaModelTest.cs +++ b/mcs/class/System.Web.DynamicData/Test/System.Web.DynamicData/MetaModelTest.cs @@ -237,8 +237,8 @@ namespace MonoTests.System.Web.DynamicData public void GetModel () { Utils.GetModel<UseOnlyInGetModelTestDataContext> (); - AssertExtensions.Throws<ArgumentNullException> (() => MetaModel.GetModel (null), "#A1"); - AssertExtensions.Throws<InvalidOperationException> (() => MetaModel.GetModel (typeof (object)), "#A2"); + Assert.Throws<ArgumentNullException> (() => MetaModel.GetModel (null), "#A1"); + Assert.Throws<InvalidOperationException> (() => MetaModel.GetModel (typeof (object)), "#A2"); Assert.IsNotNull (MetaModel.GetModel (typeof (UseOnlyInGetModelTestDataContext))); } @@ -248,7 +248,7 @@ namespace MonoTests.System.Web.DynamicData MetaModel m = Utils.GetModel<MyDataContext2> (); MetaTable t; - AssertExtensions.Throws<ArgumentNullException> (() => m.TryGetTable (null, out t), "#A1"); + Assert.Throws<ArgumentNullException> (() => m.TryGetTable (null, out t), "#A1"); Assert.IsTrue (m.TryGetTable ("FooTable", out t), "#B1"); Assert.IsNotNull (t, "#B2"); @@ -268,17 +268,17 @@ namespace MonoTests.System.Web.DynamicData string str = null; Type type = null; - AssertExtensions.Throws<ArgumentNullException> (() => t = m.GetTable (str), "#A1"); - AssertExtensions.Throws<ArgumentNullException> (() => t = m.GetTable (type), "#A2"); - AssertExtensions.Throws<ArgumentNullException> (() => t = m.GetTable (null, null), "#A3"); - AssertExtensions.Throws<ArgumentNullException> (() => t = m.GetTable (null, typeof (Foo)), "#A4"); - AssertExtensions.Throws<ArgumentNullException> (() => t = m.GetTable ("FooTable", null), "#A5"); + Assert.Throws<ArgumentNullException> (() => t = m.GetTable (str), "#A1"); + Assert.Throws<ArgumentNullException> (() => t = m.GetTable (type), "#A2"); + Assert.Throws<ArgumentNullException> (() => t = m.GetTable (null, null), "#A3"); + Assert.Throws<ArgumentNullException> (() => t = m.GetTable (null, typeof (Foo)), "#A4"); + Assert.Throws<ArgumentNullException> (() => t = m.GetTable ("FooTable", null), "#A5"); - AssertExtensions.Throws<ArgumentException> (() => t = m.GetTable (String.Empty), "#B1"); - AssertExtensions.Throws<ArgumentException> (() => t = m.GetTable ("NoSuchName"), "#B2"); - AssertExtensions.Throws<ArgumentException> (() => t = m.GetTable (typeof (object)), "#B3"); - AssertExtensions.Throws<ArgumentException> (() => t = m.GetTable ("FooTable", typeof (object)), "#B4"); - AssertExtensions.Throws<ArgumentException> (() => t = m.GetTable ("NoSuchTable", typeof (object)), "#B5"); + Assert.Throws<ArgumentException> (() => t = m.GetTable (String.Empty), "#B1"); + Assert.Throws<ArgumentException> (() => t = m.GetTable ("NoSuchName"), "#B2"); + Assert.Throws<ArgumentException> (() => t = m.GetTable (typeof (object)), "#B3"); + Assert.Throws<ArgumentException> (() => t = m.GetTable ("FooTable", typeof (object)), "#B4"); + Assert.Throws<ArgumentException> (() => t = m.GetTable ("NoSuchTable", typeof (object)), "#B5"); Assert.IsNotNull (t = m.GetTable ("FooTable"), "#C1"); Assert.AreEqual (typeof (Foo), t.EntityType, "#C2"); @@ -296,11 +296,11 @@ namespace MonoTests.System.Web.DynamicData // None of those are thrown from GetTable - it seems this method performs NO checks at all, sigh... // - //AssertExtensions.Throws<ArgumentNullException> (() => m.GetActionPath (null, PageAction.List, foo), "#A1"); - //AssertExtensions.Throws<ArgumentException> (() => m.GetActionPath (String.Empty, PageAction.List, foo), "#A2"); - //AssertExtensions.Throws<ArgumentNullException> (() => m.GetActionPath ("FooTable", null, foo), "#A3"); - //AssertExtensions.Throws<ArgumentNullException> (() => m.GetActionPath ("FooTable", PageAction.List, null), "#A4"); - //AssertExtensions.Throws<ArgumentException> (() => m.GetActionPath ("NoSuchTable", PageAction.List, foo), "#A5"); + //Assert.Throws<ArgumentNullException> (() => m.GetActionPath (null, PageAction.List, foo), "#A1"); + //Assert.Throws<ArgumentException> (() => m.GetActionPath (String.Empty, PageAction.List, foo), "#A2"); + //Assert.Throws<ArgumentNullException> (() => m.GetActionPath ("FooTable", null, foo), "#A3"); + //Assert.Throws<ArgumentNullException> (() => m.GetActionPath ("FooTable", PageAction.List, null), "#A4"); + //Assert.Throws<ArgumentException> (() => m.GetActionPath ("NoSuchTable", PageAction.List, foo), "#A5"); } [Test] @@ -323,10 +323,10 @@ namespace MonoTests.System.Web.DynamicData // // at System.Web.DynamicData.MetaModel.TryGetTable(String uniqueTableName, MetaTable& table) // at System.Web.DynamicData.MetaModel.GetTable(String uniqueTableName) - AssertExtensions.Throws<ArgumentNullException> (() => m.GetActionPath (null, PageAction.List, foo), "#A1"); + Assert.Throws<ArgumentNullException> (() => m.GetActionPath (null, PageAction.List, foo), "#A1"); Assert.AreEqual (String.Empty, m.GetActionPath ("FooTable", null, foo), "#A2"); Assert.AreEqual ("/FooTable/List.aspx", m.GetActionPath ("FooTable", PageAction.List, null), "#A3"); - AssertExtensions.Throws<ArgumentException> (() => m.GetActionPath ("NoSuchTable", PageAction.List, foo), "#A4"); + Assert.Throws<ArgumentException> (() => m.GetActionPath ("NoSuchTable", PageAction.List, foo), "#A4"); Assert.AreEqual ("/FooTable/List.aspx", m.GetActionPath ("FooTable", "List", foo), "#B1"); } diff --git a/mcs/class/System.Web.DynamicData/Test/System.Web.DynamicData/MetaTableTest.cs b/mcs/class/System.Web.DynamicData/Test/System.Web.DynamicData/MetaTableTest.cs index b51fb6d7314..0f1971dcbe9 100644 --- a/mcs/class/System.Web.DynamicData/Test/System.Web.DynamicData/MetaTableTest.cs +++ b/mcs/class/System.Web.DynamicData/Test/System.Web.DynamicData/MetaTableTest.cs @@ -170,7 +170,7 @@ namespace MonoTests.System.Web.DynamicData Assert.AreEqual ("Column2", mc.Name, "#A2"); t = m.Tables[TestDataContext.TableFooEmpty]; - AssertExtensions.Throws<ArgumentOutOfRangeException> (() => mc = t.DisplayColumn, "#B1"); + Assert.Throws<ArgumentOutOfRangeException> (() => mc = t.DisplayColumn, "#B1"); t = m.Tables[TestDataContext.TableFooWithDefaults]; mc = t.DisplayColumn; @@ -193,9 +193,9 @@ namespace MonoTests.System.Web.DynamicData Assert.AreEqual ("Column1", mc.Name, "#F2"); t = m.Tables[TestDataContext.TableFooInvalidDisplayColumnAttribute]; - AssertExtensions.Throws<InvalidOperationException> (() => mc = t.DisplayColumn, "#G1"); + Assert.Throws<InvalidOperationException> (() => mc = t.DisplayColumn, "#G1"); t = m.Tables[TestDataContext.TableFooEmptyDisplayColumnAttribute]; - AssertExtensions.Throws<InvalidOperationException> (() => mc = t.DisplayColumn, "#G2"); + Assert.Throws<InvalidOperationException> (() => mc = t.DisplayColumn, "#G2"); t = m.Tables[TestDataContext.TableFooWithMetadataType]; mc = t.DisplayColumn; @@ -369,7 +369,7 @@ namespace MonoTests.System.Web.DynamicData // Yet another lack of parameter checking - the number of items passed in the dataList must be at least equal // to the number of columns in the PrimaryKeyColumns collection - AssertExtensions.Throws<ArgumentOutOfRangeException> (() => t.GetActionPath (PageAction.Details, dataList), "#A2"); + Assert.Throws<ArgumentOutOfRangeException> (() => t.GetActionPath (PageAction.Details, dataList), "#A2"); dataList.Add (2); dataList.Add (false); @@ -401,20 +401,20 @@ namespace MonoTests.System.Web.DynamicData var values = new RouteValueDictionary (); // NO null check for the routeValues parameter _again_! - AssertExtensions.Throws<NullReferenceException> (() => t.GetActionPath (PageAction.Details, (RouteValueDictionary) null), "#A1"); + Assert.Throws<NullReferenceException> (() => t.GetActionPath (PageAction.Details, (RouteValueDictionary) null), "#A1"); Assert.AreEqual (Utils.BuildActionName (t, PageAction.Details), t.GetActionPath (PageAction.Details, values), "#A2"); Assert.AreEqual (2, values.Count, "#A3"); // GetActionPath does not check if the Action and Table keys are present in the dictionary... values.Clear (); values.Add ("Action", "something"); - AssertExtensions.Throws<ArgumentException> (() => { + Assert.Throws<ArgumentException> (() => { t.GetActionPath (PageAction.Details, values); }, "#B1"); values.Clear (); values.Add ("Table", "else"); - AssertExtensions.Throws<ArgumentException> (() => { + Assert.Throws<ArgumentException> (() => { t.GetActionPath (PageAction.Details, values); }, "#B2"); } @@ -429,7 +429,7 @@ namespace MonoTests.System.Web.DynamicData var foo = new FooWithDefaults (); Assert.AreEqual (String.Empty, t.GetActionPath (null, (object) null), "#A1"); - AssertExtensions.Throws<HttpException> (() => t.GetActionPath (PageAction.Details, (object) "test"), "#A2"); + Assert.Throws<HttpException> (() => t.GetActionPath (PageAction.Details, (object) "test"), "#A2"); Assert.AreEqual (Utils.BuildActionName (t, PageAction.Details, "PrimaryKeyColumn1=primary%20key%20value&PrimaryKeyColumn2=456&PrimaryKeyColumn3=True"), t.GetActionPath (PageAction.Details, foo), "#A3"); t = m.Tables[TestDataContext.TableFooNoDefaultsWithPrimaryKey]; @@ -490,7 +490,7 @@ namespace MonoTests.System.Web.DynamicData // Yet another lack of parameter checking - the number of items passed in the dataList must be at least equal // to the number of columns in the PrimaryKeyColumns collection - AssertExtensions.Throws<ArgumentOutOfRangeException> (() => t.GetActionPath (PageAction.Details, dataList), "#A3"); + Assert.Throws<ArgumentOutOfRangeException> (() => t.GetActionPath (PageAction.Details, dataList), "#A3"); dataList.Add (2); dataList.Add (false); @@ -540,9 +540,9 @@ namespace MonoTests.System.Web.DynamicData MetaTable t = m.Tables[TestDataContext.TableFooWithDefaults]; - AssertExtensions.Throws<ArgumentNullException> (() => t.GetColumn (null), "#A1"); - AssertExtensions.Throws<InvalidOperationException> (() => t.GetColumn (String.Empty), "#A2"); - AssertExtensions.Throws<InvalidOperationException> (() => t.GetColumn ("NoSuchColumn"), "#A3"); + Assert.Throws<ArgumentNullException> (() => t.GetColumn (null), "#A1"); + Assert.Throws<InvalidOperationException> (() => t.GetColumn (String.Empty), "#A2"); + Assert.Throws<InvalidOperationException> (() => t.GetColumn ("NoSuchColumn"), "#A3"); MetaColumn mc = t.GetColumn ("Column1"); Assert.IsNotNull (mc, "#B1"); @@ -559,9 +559,9 @@ namespace MonoTests.System.Web.DynamicData var foo = new FooWithDefaults (); Assert.AreEqual (String.Empty, t.GetDisplayString (null), "#A1"); - AssertExtensions.Throws<HttpException> (() => t.GetDisplayString (String.Empty), "#A2"); + Assert.Throws<HttpException> (() => t.GetDisplayString (String.Empty), "#A2"); Assert.AreEqual ("hello", t.GetDisplayString (foo), "#A3"); - AssertExtensions.Throws<HttpException> (() => t.GetDisplayString ("TestString"), "#A4"); + Assert.Throws<HttpException> (() => t.GetDisplayString ("TestString"), "#A4"); // The method looks at the entity type to see if it has an overriden ToString method, // it ignores such methods on the passed "row" @@ -645,7 +645,7 @@ namespace MonoTests.System.Web.DynamicData Assert.AreEqual ("primary key value,456,True", t.GetPrimaryKeyString (foo), "#A2"); var foo2 = new FooNoDefaultsWithPrimaryKey (); - AssertExtensions.Throws<HttpException> (() => t.GetPrimaryKeyString (foo2), "#B1"); + Assert.Throws<HttpException> (() => t.GetPrimaryKeyString (foo2), "#B1"); t = m.Tables[TestDataContext.TableFooSettableDefaults]; var foo3 = new FooSettableDefaults (null, null, null); @@ -668,7 +668,7 @@ namespace MonoTests.System.Web.DynamicData var foo = new FooWithDefaults (); Assert.IsNull (t.GetPrimaryKeyValues (null), "#A1"); - AssertExtensions.Throws<HttpException> (() => t.GetPrimaryKeyValues ("test"), "#A2"); + Assert.Throws<HttpException> (() => t.GetPrimaryKeyValues ("test"), "#A2"); IList<object> ret = t.GetPrimaryKeyValues (foo); Assert.IsNotNull (ret, "#B1"); @@ -780,7 +780,7 @@ namespace MonoTests.System.Web.DynamicData Assert.IsTrue (query.GetType () == typeof (Table<Foo>), "#A2"); var foo = new Foo (true); - AssertExtensions.Throws (() => t.GetQuery (foo), "#B1"); + Assert.Throws<InvalidCastException> (() => t.GetQuery (foo), "#B1"); } [Test] @@ -902,7 +902,7 @@ namespace MonoTests.System.Web.DynamicData MetaColumn mc; t = m.Tables[TestDataContext.TableFooMisnamedSortColumn]; - AssertExtensions.Throws <InvalidOperationException> (() => mc = t.SortColumn, "#C1"); + Assert.Throws <InvalidOperationException> (() => mc = t.SortColumn, "#C1"); t = m.Tables[TestDataContext.TableFooEmptySortColumn]; Assert.IsNull (t.SortColumn, "#D1"); @@ -943,7 +943,7 @@ namespace MonoTests.System.Web.DynamicData MetaTable t = m.Tables[TestDataContext.TableFooWithDefaults]; MetaColumn mc = null; - AssertExtensions.Throws<ArgumentNullException> (() => t.TryGetColumn (null, out mc), "#A1"); + Assert.Throws<ArgumentNullException> (() => t.TryGetColumn (null, out mc), "#A1"); Assert.IsFalse (t.TryGetColumn (String.Empty, out mc), "#A2"); Assert.IsNull (mc, "#A2-1"); Assert.IsTrue (t.TryGetColumn ("Column1", out mc), "#A3"); |