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.ComponentModel.DataAnnotations | |
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.ComponentModel.DataAnnotations')
12 files changed, 95 insertions, 107 deletions
diff --git a/mcs/class/System.ComponentModel.DataAnnotations/System.ComponentModel.DataAnnotations_test.dll.sources b/mcs/class/System.ComponentModel.DataAnnotations/System.ComponentModel.DataAnnotations_test.dll.sources index 70011cc02ec..9454422b250 100644 --- a/mcs/class/System.ComponentModel.DataAnnotations/System.ComponentModel.DataAnnotations_test.dll.sources +++ b/mcs/class/System.ComponentModel.DataAnnotations/System.ComponentModel.DataAnnotations_test.dll.sources @@ -1,4 +1,3 @@ -../../System.Web.DynamicData/Test/Common/AssertExtensions.cs System.ComponentModel.DataAnnotations/AssociatedMetadataTypeTypeDescriptionProviderTests.cs System.ComponentModel.DataAnnotations/AssociationAttributeTest.cs System.ComponentModel.DataAnnotations/CustomValidationAttributeTest.cs diff --git a/mcs/class/System.ComponentModel.DataAnnotations/Test/System.ComponentModel.DataAnnotations/CompareAttributeTest.cs b/mcs/class/System.ComponentModel.DataAnnotations/Test/System.ComponentModel.DataAnnotations/CompareAttributeTest.cs index d98c051699e..6a59aaf6e86 100644 --- a/mcs/class/System.ComponentModel.DataAnnotations/Test/System.ComponentModel.DataAnnotations/CompareAttributeTest.cs +++ b/mcs/class/System.ComponentModel.DataAnnotations/Test/System.ComponentModel.DataAnnotations/CompareAttributeTest.cs @@ -32,7 +32,6 @@ using System.ComponentModel.DataAnnotations; using System.Text; using NUnit.Framework; -using MonoTests.Common; namespace MonoTests.System.ComponentModel.DataAnnotations { diff --git a/mcs/class/System.ComponentModel.DataAnnotations/Test/System.ComponentModel.DataAnnotations/CreditCardAttributeTest.cs b/mcs/class/System.ComponentModel.DataAnnotations/Test/System.ComponentModel.DataAnnotations/CreditCardAttributeTest.cs index 00cc74573f4..828b089907a 100644 --- a/mcs/class/System.ComponentModel.DataAnnotations/Test/System.ComponentModel.DataAnnotations/CreditCardAttributeTest.cs +++ b/mcs/class/System.ComponentModel.DataAnnotations/Test/System.ComponentModel.DataAnnotations/CreditCardAttributeTest.cs @@ -32,7 +32,6 @@ using System.ComponentModel.DataAnnotations; using System.Text; using NUnit.Framework; -using MonoTests.Common; namespace MonoTests.System.ComponentModel.DataAnnotations { diff --git a/mcs/class/System.ComponentModel.DataAnnotations/Test/System.ComponentModel.DataAnnotations/CustomValidationAttributeTest.cs b/mcs/class/System.ComponentModel.DataAnnotations/Test/System.ComponentModel.DataAnnotations/CustomValidationAttributeTest.cs index 2cef47f844b..f012fd289ea 100644 --- a/mcs/class/System.ComponentModel.DataAnnotations/Test/System.ComponentModel.DataAnnotations/CustomValidationAttributeTest.cs +++ b/mcs/class/System.ComponentModel.DataAnnotations/Test/System.ComponentModel.DataAnnotations/CustomValidationAttributeTest.cs @@ -30,7 +30,6 @@ using System.ComponentModel.Design; using System.Text; using NUnit.Framework; -using MonoTests.Common; namespace MonoTests.System.ComponentModel.DataAnnotations { @@ -86,7 +85,7 @@ namespace MonoTests.System.ComponentModel.DataAnnotations var attr = new CustomValidationAttribute (null, null); string msg = null; - AssertExtensions.Throws<InvalidOperationException> (() => { + Assert.Throws<InvalidOperationException> (() => { // MonoTests.System.ComponentModel.DataAnnotations.CustomValidationAttributeTest.FormatErrorMessage: // System.InvalidOperationException : The CustomValidationAttribute.ValidatorType was not specified. // @@ -98,7 +97,7 @@ namespace MonoTests.System.ComponentModel.DataAnnotations }, "#A1"); attr = new CustomValidationAttribute (typeof (string), null); - AssertExtensions.Throws<InvalidOperationException> (() => { + Assert.Throws<InvalidOperationException> (() => { // MonoTests.System.ComponentModel.DataAnnotations.CustomValidationAttributeTest.FormatErrorMessage: // System.InvalidOperationException : The CustomValidationAttribute.Method was not specified. // @@ -110,7 +109,7 @@ namespace MonoTests.System.ComponentModel.DataAnnotations }, "#A2"); attr = new CustomValidationAttribute (typeof (string), String.Empty); - AssertExtensions.Throws<InvalidOperationException> (() => { + Assert.Throws<InvalidOperationException> (() => { // MonoTests.System.ComponentModel.DataAnnotations.CustomValidationAttributeTest.FormatErrorMessage: // System.InvalidOperationException : The CustomValidationAttribute.Method was not specified. // @@ -122,7 +121,7 @@ namespace MonoTests.System.ComponentModel.DataAnnotations }, "#A3"); attr = new CustomValidationAttribute (typeof (string), "NoSuchMethod"); - AssertExtensions.Throws<InvalidOperationException> (() => { + Assert.Throws<InvalidOperationException> (() => { // MonoTests.System.ComponentModel.DataAnnotations.CustomValidationAttributeTest.FormatErrorMessage: // System.InvalidOperationException : The CustomValidationAttribute method 'NoSuchMethod' does not exist in type 'String' or is not public and static. // @@ -134,7 +133,7 @@ namespace MonoTests.System.ComponentModel.DataAnnotations }, "#A4"); attr = new CustomValidationAttribute (typeof (PrivateValidatorMethodContainer), "MethodOne"); - AssertExtensions.Throws<InvalidOperationException> (() => { + Assert.Throws<InvalidOperationException> (() => { // MonoTests.System.ComponentModel.DataAnnotations.CustomValidationAttributeTest.FormatErrorMessage: // System.InvalidOperationException : The custom validation type 'PrivateValidatorMethodContainer' must be public. // @@ -146,7 +145,7 @@ namespace MonoTests.System.ComponentModel.DataAnnotations }, "#A5"); attr = new CustomValidationAttribute (typeof (PublicValidatorMethodContainer), "MethodOne"); - AssertExtensions.Throws<InvalidOperationException> (() => { + Assert.Throws<InvalidOperationException> (() => { // MonoTests.System.ComponentModel.DataAnnotations.CustomValidationAttributeTest.FormatErrorMessage: // System.InvalidOperationException : The CustomValidationAttribute method 'MethodOne' in type 'PublicValidatorMethodContainer' // must return System.ComponentModel.DataAnnotations.ValidationResult. Use System.ComponentModel.DataAnnotations.ValidationResult.Success @@ -159,7 +158,7 @@ namespace MonoTests.System.ComponentModel.DataAnnotations }, "#A6"); attr = new CustomValidationAttribute (typeof (PublicValidatorMethodContainer), "MethodTwo"); - AssertExtensions.Throws<InvalidOperationException> (() => { + Assert.Throws<InvalidOperationException> (() => { // MonoTests.System.ComponentModel.DataAnnotations.CustomValidationAttributeTest.FormatErrorMessage: // System.InvalidOperationException : The CustomValidationAttribute method 'MethodTwo' in type 'PublicValidatorMethodContainer' must match the expected signature: public static ValidationResult MethodTwo(object value, ValidationContext context). The value can be strongly typed. The ValidationContext parameter is optional. // @@ -182,7 +181,7 @@ namespace MonoTests.System.ComponentModel.DataAnnotations Assert.AreEqual ("test is not valid.", msg, "#A9-3"); attr = new CustomValidationAttribute (typeof (PublicValidatorMethodContainer), "MethodFive"); - AssertExtensions.Throws<InvalidOperationException> (() => { + Assert.Throws<InvalidOperationException> (() => { // MonoTests.System.ComponentModel.DataAnnotations.CustomValidationAttributeTest.FormatErrorMessage: // System.InvalidOperationException : The CustomValidationAttribute method 'MethodFive' in type 'PublicValidatorMethodContainer' must match the expected signature: public static ValidationResult MethodFive(object value, ValidationContext context). The value can be strongly typed. The ValidationContext parameter is optional. // @@ -193,7 +192,7 @@ namespace MonoTests.System.ComponentModel.DataAnnotations }, "#A10"); attr = new CustomValidationAttribute (typeof (PublicValidatorMethodContainer), "MethodSix"); - AssertExtensions.Throws<InvalidOperationException> (() => { + Assert.Throws<InvalidOperationException> (() => { // MonoTests.System.ComponentModel.DataAnnotations.CustomValidationAttributeTest.FormatErrorMessage: // System.InvalidOperationException : The CustomValidationAttribute method 'MethodSix' in type 'PublicValidatorMethodContainer' must match the expected signature: public static ValidationResult MethodSix(object value, ValidationContext context). The value can be strongly typed. The ValidationContext parameter is optional. // @@ -209,37 +208,37 @@ namespace MonoTests.System.ComponentModel.DataAnnotations { var attr = new CustomValidationAttribute (null, null); - AssertExtensions.Throws<InvalidOperationException> (() => { + Assert.Throws<InvalidOperationException> (() => { attr.IsValid ("test"); }, "#A1"); attr = new CustomValidationAttribute (typeof (string), null); - AssertExtensions.Throws<InvalidOperationException> (() => { + Assert.Throws<InvalidOperationException> (() => { attr.IsValid ("test"); }, "#A2"); attr = new CustomValidationAttribute (typeof (string), String.Empty); - AssertExtensions.Throws<InvalidOperationException> (() => { + Assert.Throws<InvalidOperationException> (() => { attr.IsValid ("test"); }, "#A3"); attr = new CustomValidationAttribute (typeof (string), "NoSuchMethod"); - AssertExtensions.Throws<InvalidOperationException> (() => { + Assert.Throws<InvalidOperationException> (() => { attr.IsValid ("test"); }, "#A4"); attr = new CustomValidationAttribute (typeof (PrivateValidatorMethodContainer), "MethodOne"); - AssertExtensions.Throws<InvalidOperationException> (() => { + Assert.Throws<InvalidOperationException> (() => { attr.IsValid ("test"); }, "#A5"); attr = new CustomValidationAttribute (typeof (PublicValidatorMethodContainer), "MethodOne"); - AssertExtensions.Throws<InvalidOperationException> (() => { + Assert.Throws<InvalidOperationException> (() => { attr.IsValid ("test"); }, "#A6"); attr = new CustomValidationAttribute (typeof (PublicValidatorMethodContainer), "MethodTwo"); - AssertExtensions.Throws<InvalidOperationException> (() => { + Assert.Throws<InvalidOperationException> (() => { attr.IsValid ("test"); }, "#A7"); @@ -260,17 +259,17 @@ namespace MonoTests.System.ComponentModel.DataAnnotations Assert.IsFalse (valid, "#A9-3"); attr = new CustomValidationAttribute (typeof (PublicValidatorMethodContainer), "MethodFive"); - AssertExtensions.Throws<InvalidOperationException> (() => { + Assert.Throws<InvalidOperationException> (() => { attr.IsValid ("test"); }, "#A10"); attr = new CustomValidationAttribute (typeof (PublicValidatorMethodContainer), "MethodSix"); - AssertExtensions.Throws<InvalidOperationException> (() => { + Assert.Throws<InvalidOperationException> (() => { attr.IsValid ("test"); }, "#A11"); attr = new CustomValidationAttribute (typeof (PublicValidatorMethodContainer), "MethodSeven"); - AssertExtensions.Throws<ApplicationException> (() => { + Assert.Throws<ApplicationException> (() => { attr.IsValid ("test"); }, "#A12"); } diff --git a/mcs/class/System.ComponentModel.DataAnnotations/Test/System.ComponentModel.DataAnnotations/EmailAddressAttributeTest.cs b/mcs/class/System.ComponentModel.DataAnnotations/Test/System.ComponentModel.DataAnnotations/EmailAddressAttributeTest.cs index f85887cef65..e812389d2c5 100644 --- a/mcs/class/System.ComponentModel.DataAnnotations/Test/System.ComponentModel.DataAnnotations/EmailAddressAttributeTest.cs +++ b/mcs/class/System.ComponentModel.DataAnnotations/Test/System.ComponentModel.DataAnnotations/EmailAddressAttributeTest.cs @@ -32,7 +32,6 @@ using System.ComponentModel.DataAnnotations; using System.Text; using NUnit.Framework; -using MonoTests.Common; namespace MonoTests.System.ComponentModel.DataAnnotations { diff --git a/mcs/class/System.ComponentModel.DataAnnotations/Test/System.ComponentModel.DataAnnotations/FileExtensionsAttributeTest.cs b/mcs/class/System.ComponentModel.DataAnnotations/Test/System.ComponentModel.DataAnnotations/FileExtensionsAttributeTest.cs index 6ef0263365c..f7a93a58979 100644 --- a/mcs/class/System.ComponentModel.DataAnnotations/Test/System.ComponentModel.DataAnnotations/FileExtensionsAttributeTest.cs +++ b/mcs/class/System.ComponentModel.DataAnnotations/Test/System.ComponentModel.DataAnnotations/FileExtensionsAttributeTest.cs @@ -32,7 +32,6 @@ using System.ComponentModel.DataAnnotations; using System.Text; using NUnit.Framework; -using MonoTests.Common; namespace MonoTests.System.ComponentModel.DataAnnotations { diff --git a/mcs/class/System.ComponentModel.DataAnnotations/Test/System.ComponentModel.DataAnnotations/PhoneAttributeTest.cs b/mcs/class/System.ComponentModel.DataAnnotations/Test/System.ComponentModel.DataAnnotations/PhoneAttributeTest.cs index ef9c95dfb75..cac863fe637 100644 --- a/mcs/class/System.ComponentModel.DataAnnotations/Test/System.ComponentModel.DataAnnotations/PhoneAttributeTest.cs +++ b/mcs/class/System.ComponentModel.DataAnnotations/Test/System.ComponentModel.DataAnnotations/PhoneAttributeTest.cs @@ -32,7 +32,6 @@ using System.ComponentModel.DataAnnotations; using System.Text; using NUnit.Framework; -using MonoTests.Common; namespace MonoTests.System.ComponentModel.DataAnnotations { diff --git a/mcs/class/System.ComponentModel.DataAnnotations/Test/System.ComponentModel.DataAnnotations/RangeAttributeTest.cs b/mcs/class/System.ComponentModel.DataAnnotations/Test/System.ComponentModel.DataAnnotations/RangeAttributeTest.cs index 1f297263792..d16174fd892 100644 --- a/mcs/class/System.ComponentModel.DataAnnotations/Test/System.ComponentModel.DataAnnotations/RangeAttributeTest.cs +++ b/mcs/class/System.ComponentModel.DataAnnotations/Test/System.ComponentModel.DataAnnotations/RangeAttributeTest.cs @@ -31,7 +31,6 @@ using System.ComponentModel.DataAnnotations; using System.Text; using NUnit.Framework; -using MonoTests.Common; using DA = global::System.ComponentModel.DataAnnotations; @@ -130,49 +129,49 @@ namespace MonoTests.System.ComponentModel.DataAnnotations Assert.IsFalse (attr.IsValid ("12"), "#A1-2"); Assert.IsTrue (attr.IsValid (null), "#A1-3"); Assert.IsTrue (attr.IsValid (String.Empty), "#A1-4"); - AssertExtensions.Throws <Exception> (() => { + Assert.Throws <Exception> (() => { attr.IsValid ("zero"); }, "#A1-5"); Assert.IsTrue (attr.IsValid (null), "#A1-6"); attr = new DA.RangeAttribute (typeof (int), "minus ten", "ten"); - AssertExtensions.Throws<Exception> (() => { + Assert.Throws<Exception> (() => { attr.IsValid ("0"); }, "#A2-1"); - AssertExtensions.Throws<Exception> (() => { + Assert.Throws<Exception> (() => { attr.IsValid ("12"); }, "#A2-2"); - AssertExtensions.Throws<Exception> (() => { + Assert.Throws<Exception> (() => { attr.IsValid ("zero"); }, "#A2-3"); attr = new DA.RangeAttribute (typeof (RangeAttributeTest), "-10", "10"); - AssertExtensions.Throws<InvalidOperationException> (() => { + Assert.Throws<InvalidOperationException> (() => { attr.IsValid (null); }, "#A3-1"); - AssertExtensions.Throws<InvalidOperationException> (() => { + Assert.Throws<InvalidOperationException> (() => { attr.IsValid (String.Empty); }, "#A3-2"); - AssertExtensions.Throws<InvalidOperationException> (() => { + Assert.Throws<InvalidOperationException> (() => { // The type MonoTests.System.ComponentModel.DataAnnotations.RangeAttributeTest must implement System.IComparable. attr.IsValid ("10"); }, "#A3-3"); attr = new DA.RangeAttribute (null, "-10", "10"); - AssertExtensions.Throws<InvalidOperationException> (() => { + Assert.Throws<InvalidOperationException> (() => { // The OperandType must be set when strings are used for minimum and maximum values. attr.IsValid ("10"); }, "#A4"); attr = new DA.RangeAttribute (typeof (int), null, "10"); - AssertExtensions.Throws<InvalidOperationException> (() => { + Assert.Throws<InvalidOperationException> (() => { // The minimum and maximum values must be set. attr.IsValid (10); }, "#A5-1"); attr = new DA.RangeAttribute (typeof (int), "10", null); - AssertExtensions.Throws<InvalidOperationException> (() => { + Assert.Throws<InvalidOperationException> (() => { // The minimum and maximum values must be set. attr.IsValid (10); }, "#A5-2"); @@ -201,7 +200,7 @@ namespace MonoTests.System.ComponentModel.DataAnnotations attr.ErrorMessage = "Param 0: {0}; Param 1: {1}; Param 2: {2}"; Assert.AreEqual ("Param 0: MyField; Param 1: -10; Param 2: 10", attr.FormatErrorMessage ("MyField"), "#A2-3"); attr.ErrorMessage = "Param 0: {0}; Param 1: {1}; Param 2: {2}; Param 3: {3}"; - AssertExtensions.Throws<FormatException> (() => { + Assert.Throws<FormatException> (() => { attr.FormatErrorMessage ("MyField"); }, "#A2-1"); } diff --git a/mcs/class/System.ComponentModel.DataAnnotations/Test/System.ComponentModel.DataAnnotations/RegularExpressionAttributeTest.cs b/mcs/class/System.ComponentModel.DataAnnotations/Test/System.ComponentModel.DataAnnotations/RegularExpressionAttributeTest.cs index bb9852e1fc9..63971b66d22 100644 --- a/mcs/class/System.ComponentModel.DataAnnotations/Test/System.ComponentModel.DataAnnotations/RegularExpressionAttributeTest.cs +++ b/mcs/class/System.ComponentModel.DataAnnotations/Test/System.ComponentModel.DataAnnotations/RegularExpressionAttributeTest.cs @@ -31,7 +31,6 @@ using System.ComponentModel.DataAnnotations; using System.Text; using NUnit.Framework; -using MonoTests.Common; namespace MonoTests.System.ComponentModel.DataAnnotations { @@ -94,15 +93,15 @@ namespace MonoTests.System.ComponentModel.DataAnnotations rea = new RegularExpressionAttributePoker (""); - AssertExtensions.Throws<InvalidOperationException> (() => { + Assert.Throws<InvalidOperationException> (() => { rea.IsValid (null); }, "null does not match empty pattern"); - AssertExtensions.Throws<InvalidOperationException> (() => { + Assert.Throws<InvalidOperationException> (() => { rea.IsValid (String.Empty); }, "empty string does not match empty pattern"); - AssertExtensions.Throws<InvalidOperationException> (() => { + Assert.Throws<InvalidOperationException> (() => { rea.IsValid ("string"); }, "'string' does not match empty pattern"); diff --git a/mcs/class/System.ComponentModel.DataAnnotations/Test/System.ComponentModel.DataAnnotations/StringLengthAttributeTest.cs b/mcs/class/System.ComponentModel.DataAnnotations/Test/System.ComponentModel.DataAnnotations/StringLengthAttributeTest.cs index 61b61683e69..e6daa9d4e41 100644 --- a/mcs/class/System.ComponentModel.DataAnnotations/Test/System.ComponentModel.DataAnnotations/StringLengthAttributeTest.cs +++ b/mcs/class/System.ComponentModel.DataAnnotations/Test/System.ComponentModel.DataAnnotations/StringLengthAttributeTest.cs @@ -31,7 +31,6 @@ using System.ComponentModel.DataAnnotations; using System.Text; using NUnit.Framework; -using MonoTests.Common; namespace MonoTests.System.ComponentModel.DataAnnotations { @@ -89,10 +88,10 @@ namespace MonoTests.System.ComponentModel.DataAnnotations Assert.IsTrue (sla.IsValid ("string"), "#A1-3"); Assert.IsTrue (sla.IsValid ("0123456789"), "#A1-4"); Assert.IsFalse (sla.IsValid ("0123456789A"), "#A1-5"); - AssertExtensions.Throws<InvalidCastException> (() => { + Assert.Throws<InvalidCastException> (() => { sla.IsValid (123); }, "#A1-6"); - AssertExtensions.Throws<InvalidCastException> (() => { + Assert.Throws<InvalidCastException> (() => { sla.IsValid (DateTime.Now); }, "#A1-7"); @@ -101,13 +100,13 @@ namespace MonoTests.System.ComponentModel.DataAnnotations Assert.IsTrue (sla.IsValid (String.Empty), "#B1-2"); Assert.IsFalse (sla.IsValid ("string"), "#B1-3"); sla = new StringLengthAttributePoker (-10); - AssertExtensions.Throws <InvalidOperationException> (() => { + Assert.Throws <InvalidOperationException> (() => { sla.IsValid ("123"); }, "#C1-1"); sla = new StringLengthAttributePoker (10); sla.MinimumLength = 20; - AssertExtensions.Throws<InvalidOperationException> (() => { + Assert.Throws<InvalidOperationException> (() => { sla.IsValid ("123"); }, "#C1-2"); diff --git a/mcs/class/System.ComponentModel.DataAnnotations/Test/System.ComponentModel.DataAnnotations/ValidationAttributeTest.cs b/mcs/class/System.ComponentModel.DataAnnotations/Test/System.ComponentModel.DataAnnotations/ValidationAttributeTest.cs index 0d8bdc4e4ab..712d37185e3 100644 --- a/mcs/class/System.ComponentModel.DataAnnotations/Test/System.ComponentModel.DataAnnotations/ValidationAttributeTest.cs +++ b/mcs/class/System.ComponentModel.DataAnnotations/Test/System.ComponentModel.DataAnnotations/ValidationAttributeTest.cs @@ -31,7 +31,6 @@ using System.ComponentModel.DataAnnotations; using System.Text; using NUnit.Framework; -using MonoTests.Common; namespace MonoTests.System.ComponentModel.DataAnnotations { @@ -351,7 +350,7 @@ namespace MonoTests.System.ComponentModel.DataAnnotations { var attr = new ValidateFooAttribute (); - AssertExtensions.Throws <NotImplementedException> (() => { + Assert.Throws <NotImplementedException> (() => { // It calls IsValid (object, validationContext) which throws the NIEX, but when that overload is called directly, there's // no exception. // @@ -361,7 +360,7 @@ namespace MonoTests.System.ComponentModel.DataAnnotations attr.IsValid (null); }, "#A1-1"); - AssertExtensions.Throws <NotImplementedException> (() => { + Assert.Throws <NotImplementedException> (() => { attr.IsValid ("stuff"); }, "#A1-2"); } @@ -371,7 +370,7 @@ namespace MonoTests.System.ComponentModel.DataAnnotations { var attr = new ValidateBarAttribute (); - AssertExtensions.Throws <NullReferenceException> (() => { + Assert.Throws <NullReferenceException> (() => { attr.CallIsValid (null, null); }, "#A1"); @@ -406,7 +405,7 @@ namespace MonoTests.System.ComponentModel.DataAnnotations { var attr = new ValidateSomethingAttribute (); - AssertExtensions.Throws<NotImplementedException> (() => { + Assert.Throws<NotImplementedException> (() => { // Thrown from the IsValid (object, ValidationContext) overload! // // MonoTests.System.ComponentModel.DataAnnotations.ValidationAttributeTest.IsValid_Object_ValidationContext_02: diff --git a/mcs/class/System.ComponentModel.DataAnnotations/Test/System.ComponentModel.DataAnnotations/ValidatorTest.cs b/mcs/class/System.ComponentModel.DataAnnotations/Test/System.ComponentModel.DataAnnotations/ValidatorTest.cs index abb1e9f5156..f950b6a2773 100644 --- a/mcs/class/System.ComponentModel.DataAnnotations/Test/System.ComponentModel.DataAnnotations/ValidatorTest.cs +++ b/mcs/class/System.ComponentModel.DataAnnotations/Test/System.ComponentModel.DataAnnotations/ValidatorTest.cs @@ -29,7 +29,6 @@ using System.ComponentModel.DataAnnotations; using System.Text; using NUnit.Framework; -using MonoTests.Common; namespace MonoTests.System.ComponentModel.DataAnnotations { @@ -43,11 +42,11 @@ namespace MonoTests.System.ComponentModel.DataAnnotations var ctx = new ValidationContext (dummy, null, null); var results = new List<ValidationResult> (); - AssertExtensions.Throws<ArgumentNullException> (() => { + Assert.Throws<ArgumentNullException> (() => { Validator.TryValidateObject (null, ctx, results); }, "#A1-1"); - AssertExtensions.Throws<ArgumentNullException> (() => { + Assert.Throws<ArgumentNullException> (() => { Validator.TryValidateObject (dummy, null, results); }, "#A1-2"); @@ -70,7 +69,7 @@ namespace MonoTests.System.ComponentModel.DataAnnotations dummy = new Dummy { NameField = null }; - AssertExtensions.Throws<ArgumentException> (() => { + Assert.Throws<ArgumentException> (() => { // The instance provided must match the ObjectInstance on the ValidationContext supplied. valid = Validator.TryValidateObject (dummy, ctx, results); }, "#A2"); @@ -133,11 +132,11 @@ namespace MonoTests.System.ComponentModel.DataAnnotations var ctx = new ValidationContext (dummy, null, null); var results = new List<ValidationResult> (); - AssertExtensions.Throws<ArgumentNullException> (() => { + Assert.Throws<ArgumentNullException> (() => { Validator.TryValidateObject (null, ctx, results, false); }, "#A1-1"); - AssertExtensions.Throws<ArgumentNullException> (() => { + Assert.Throws<ArgumentNullException> (() => { Validator.TryValidateObject (dummy, null, results, false); }, "#A1-2"); @@ -168,12 +167,12 @@ namespace MonoTests.System.ComponentModel.DataAnnotations dummy = new Dummy { NameField = null }; - AssertExtensions.Throws<ArgumentException> (() => { + Assert.Throws<ArgumentException> (() => { // The instance provided must match the ObjectInstance on the ValidationContext supplied. valid = Validator.TryValidateObject (dummy, ctx, results, false); }, "#A2-1"); - AssertExtensions.Throws<ArgumentException> (() => { + Assert.Throws<ArgumentException> (() => { // The instance provided must match the ObjectInstance on the ValidationContext supplied. valid = Validator.TryValidateObject (dummy, ctx, results, true); }, "#A2-2"); @@ -269,7 +268,7 @@ namespace MonoTests.System.ComponentModel.DataAnnotations var dummy2 = new DummyWithException (); ctx = new ValidationContext (dummy2, null, null); - AssertExtensions.Throws<ApplicationException> (() => { + Assert.Throws<ApplicationException> (() => { Validator.TryValidateObject (dummy2, ctx, results, true); }, "#A9"); } @@ -283,7 +282,7 @@ namespace MonoTests.System.ComponentModel.DataAnnotations }; var results = new List<ValidationResult> (); - AssertExtensions.Throws<ArgumentException> (() => { + Assert.Throws<ArgumentException> (() => { // MonoTests.System.ComponentModel.DataAnnotations.ValidatorTest.TryValidateProperty: // System.ArgumentException : The type 'DummyNoAttributes' does not contain a public property named 'NameProperty'. // Parameter name: propertyName @@ -297,7 +296,7 @@ namespace MonoTests.System.ComponentModel.DataAnnotations }, "#A1-1"); Assert.AreEqual (0, results.Count, "#A1-2"); - AssertExtensions.Throws<ArgumentNullException> (() => { + Assert.Throws<ArgumentNullException> (() => { Validator.TryValidateProperty ("dummy", null, results); }, "#A1-2"); @@ -314,12 +313,12 @@ namespace MonoTests.System.ComponentModel.DataAnnotations MemberName = "MinMaxProperty" }; - AssertExtensions.Throws<ArgumentException> (() => { + Assert.Throws<ArgumentException> (() => { Validator.TryValidateProperty (null, ctx, results); }, "#A1-5"); ctx = new ValidationContext (dummy2, null, null); - AssertExtensions.Throws<ArgumentNullException> (() => { + Assert.Throws<ArgumentNullException> (() => { // MonoTests.System.ComponentModel.DataAnnotations.ValidatorTest.TryValidateProperty: // System.ArgumentNullException : Value cannot be null. // Parameter name: propertyName @@ -338,7 +337,7 @@ namespace MonoTests.System.ComponentModel.DataAnnotations MemberName = String.Empty }; - AssertExtensions.Throws<ArgumentNullException> (() => { + Assert.Throws<ArgumentNullException> (() => { // MonoTests.System.ComponentModel.DataAnnotations.ValidatorTest.TryValidateProperty: // System.ArgumentNullException : Value cannot be null. // Parameter name: propertyName @@ -358,7 +357,7 @@ namespace MonoTests.System.ComponentModel.DataAnnotations MemberName = "NameProperty" }; - AssertExtensions.Throws<ArgumentException> (() => { + Assert.Throws<ArgumentException> (() => { // MonoTests.System.ComponentModel.DataAnnotations.ValidatorTest.TryValidateProperty: // System.ArgumentException : The value for property 'NameProperty' must be of type 'System.String'. // Parameter name: value @@ -429,7 +428,7 @@ namespace MonoTests.System.ComponentModel.DataAnnotations Assert.IsTrue (valid, "#A1-1"); Assert.AreEqual (0, results.Count, "#A1-2"); - AssertExtensions.Throws<ArgumentNullException> (() => { + Assert.Throws<ArgumentNullException> (() => { Validator.TryValidateValue ("dummy", null, results, attributes); }, "#A2"); @@ -437,7 +436,7 @@ namespace MonoTests.System.ComponentModel.DataAnnotations Assert.IsTrue (valid, "#A3-1"); Assert.AreEqual (0, results.Count, "#A3-2"); - AssertExtensions.Throws<ArgumentNullException> (() => { + Assert.Throws<ArgumentNullException> (() => { Validator.TryValidateValue ("dummy", ctx, results, null); }, "#A4"); } @@ -464,7 +463,7 @@ namespace MonoTests.System.ComponentModel.DataAnnotations results.Clear (); log.Clear (); - AssertExtensions.Throws<InvalidCastException> (() => { + Assert.Throws<InvalidCastException> (() => { // Thrown by StringValidatorAttribute Validator.TryValidateValue (1234, ctx, results, attributes); }, "#A2-1"); @@ -490,7 +489,7 @@ namespace MonoTests.System.ComponentModel.DataAnnotations attributes.RemoveAt (2); attributes.RemoveAt (2); - AssertExtensions.Throws<ArgumentNullException> (() => { + Assert.Throws<ArgumentNullException> (() => { Validator.TryValidateValue ("dummy", null, results, attributes); }, "#B1"); @@ -498,7 +497,7 @@ namespace MonoTests.System.ComponentModel.DataAnnotations Assert.IsTrue (valid, "#B2-1"); Assert.AreEqual (0, results.Count, "#B2-2"); - AssertExtensions.Throws<ArgumentNullException> (() => { + Assert.Throws<ArgumentNullException> (() => { Validator.TryValidateValue ("dummy", ctx, results, null); }, "#B3"); } @@ -509,11 +508,11 @@ namespace MonoTests.System.ComponentModel.DataAnnotations var dummy = new DummyNoAttributes (); var ctx = new ValidationContext (dummy, null, null); - AssertExtensions.Throws<ArgumentNullException> (() => { + Assert.Throws<ArgumentNullException> (() => { Validator.ValidateObject (null, ctx); }, "#A1-1"); - AssertExtensions.Throws<ArgumentNullException> (() => { + Assert.Throws<ArgumentNullException> (() => { Validator.ValidateObject (dummy, null); }, "#A1-2"); @@ -539,7 +538,7 @@ namespace MonoTests.System.ComponentModel.DataAnnotations dummy = new Dummy { NameField = null }; - AssertExtensions.Throws<ArgumentException> (() => { + Assert.Throws<ArgumentException> (() => { // The instance provided must match the ObjectInstance on the ValidationContext supplied. Validator.ValidateObject (dummy, ctx); }, "#A2"); @@ -566,7 +565,7 @@ namespace MonoTests.System.ComponentModel.DataAnnotations RequiredDummyProperty = null }; ctx = new ValidationContext (dummy, null, null); - AssertExtensions.Throws<ValidationException> (() => { + Assert.Throws<ValidationException> (() => { Validator.ValidateObject (dummy, ctx); }, "#A5"); @@ -595,7 +594,7 @@ namespace MonoTests.System.ComponentModel.DataAnnotations FailValidation = true }; ctx = new ValidationContext (dummy, null, null); - AssertExtensions.Throws<ValidationException> (() => { + Assert.Throws<ValidationException> (() => { Validator.ValidateObject (dummy, ctx); }, "#A8"); @@ -614,11 +613,11 @@ namespace MonoTests.System.ComponentModel.DataAnnotations var dummy = new DummyNoAttributes (); var ctx = new ValidationContext (dummy, null, null); - AssertExtensions.Throws<ArgumentNullException> (() => { + Assert.Throws<ArgumentNullException> (() => { Validator.ValidateObject (null, ctx, false); }, "#A1-1"); - AssertExtensions.Throws<ArgumentNullException> (() => { + Assert.Throws<ArgumentNullException> (() => { Validator.ValidateObject (dummy, null, false); }, "#A1-2"); @@ -656,12 +655,12 @@ namespace MonoTests.System.ComponentModel.DataAnnotations dummy = new Dummy { NameField = null }; - AssertExtensions.Throws<ArgumentException> (() => { + Assert.Throws<ArgumentException> (() => { // The instance provided must match the ObjectInstance on the ValidationContext supplied. Validator.ValidateObject (dummy, ctx, false); }, "#A3-1"); - AssertExtensions.Throws<ArgumentException> (() => { + Assert.Throws<ArgumentException> (() => { // The instance provided must match the ObjectInstance on the ValidationContext supplied. Validator.ValidateObject (dummy, ctx, true); }, "#A3-2"); @@ -701,11 +700,11 @@ namespace MonoTests.System.ComponentModel.DataAnnotations RequiredDummyProperty = null }; ctx = new ValidationContext (dummy, null, null); - AssertExtensions.Throws<ValidationException> (() => { + Assert.Throws<ValidationException> (() => { Validator.ValidateObject (dummy, ctx, false); }, "#A6-1"); - AssertExtensions.Throws<ValidationException> (() => { + Assert.Throws<ValidationException> (() => { Validator.ValidateObject (dummy, ctx, true); }, "#A6-2"); @@ -727,12 +726,12 @@ namespace MonoTests.System.ComponentModel.DataAnnotations } dummy.NameProperty = "0"; - AssertExtensions.Throws<ValidationException> (() => { + Assert.Throws<ValidationException> (() => { Validator.ValidateObject (dummy, ctx, true); }, "#A9"); dummy.NameProperty = "name too long (invalid value)"; - AssertExtensions.Throws<ValidationException> (() => { + Assert.Throws<ValidationException> (() => { Validator.ValidateObject (dummy, ctx, true); }, "#A10"); @@ -746,7 +745,7 @@ namespace MonoTests.System.ComponentModel.DataAnnotations Assert.Fail ("#A11 (exception {0} thrown: {1})", ex.GetType (), ex.Message); } - AssertExtensions.Throws<ValidationException> (() => { + Assert.Throws<ValidationException> (() => { Validator.ValidateObject (dummy, ctx, true); }, "#A12"); @@ -754,17 +753,17 @@ namespace MonoTests.System.ComponentModel.DataAnnotations FailValidation = true }; ctx = new ValidationContext (dummy, null, null); - AssertExtensions.Throws<ValidationException> (() => { + Assert.Throws<ValidationException> (() => { Validator.ValidateObject (dummy, ctx, false); }, "#A13-1"); - AssertExtensions.Throws<ValidationException> (() => { + Assert.Throws<ValidationException> (() => { Validator.ValidateObject (dummy, ctx, true); }, "#A13-2"); var dummy2 = new DummyWithException (); ctx = new ValidationContext (dummy2, null, null); - AssertExtensions.Throws<ApplicationException> (() => { + Assert.Throws<ApplicationException> (() => { Validator.ValidateObject (dummy2, ctx, true); }, "#A14"); @@ -793,11 +792,11 @@ namespace MonoTests.System.ComponentModel.DataAnnotations MemberName = "NameProperty" }; - AssertExtensions.Throws<ArgumentException> (() => { + Assert.Throws<ArgumentException> (() => { Validator.ValidateProperty ("dummy", ctx); }, "#A1-1"); - AssertExtensions.Throws<ArgumentNullException> (() => { + Assert.Throws<ArgumentNullException> (() => { Validator.ValidateProperty ("dummy", null); }, "#A1-2"); @@ -816,12 +815,12 @@ namespace MonoTests.System.ComponentModel.DataAnnotations MemberName = "MinMaxProperty" }; - AssertExtensions.Throws<ArgumentException> (() => { + Assert.Throws<ArgumentException> (() => { Validator.ValidateProperty (null, ctx); }, "#A3"); ctx = new ValidationContext (dummy2, null, null); - AssertExtensions.Throws<ArgumentNullException> (() => { + Assert.Throws<ArgumentNullException> (() => { Validator.ValidateProperty ("dummy", ctx); }, "#A4"); @@ -829,7 +828,7 @@ namespace MonoTests.System.ComponentModel.DataAnnotations MemberName = String.Empty }; - AssertExtensions.Throws<ArgumentNullException> (() => { + Assert.Throws<ArgumentNullException> (() => { Validator.ValidateProperty ("dummy", ctx); }, "#A5"); @@ -838,7 +837,7 @@ namespace MonoTests.System.ComponentModel.DataAnnotations MemberName = "NameProperty" }; - AssertExtensions.Throws<ArgumentException> (() => { + Assert.Throws<ArgumentException> (() => { Validator.ValidateProperty (1234, ctx); }, "#A6"); @@ -847,11 +846,11 @@ namespace MonoTests.System.ComponentModel.DataAnnotations MemberName = "NameProperty" }; - AssertExtensions.Throws<ValidationException> (() => { + Assert.Throws<ValidationException> (() => { Validator.ValidateProperty (String.Empty, ctx); }, "#A7"); - AssertExtensions.Throws<ValidationException> (() => { + Assert.Throws<ValidationException> (() => { Validator.ValidateProperty ("this value is way too long", ctx); }, "#A8"); @@ -866,15 +865,15 @@ namespace MonoTests.System.ComponentModel.DataAnnotations MemberName = "CustomValidatedProperty" }; - AssertExtensions.Throws<ValidationException> (() => { + Assert.Throws<ValidationException> (() => { Validator.ValidateProperty (String.Empty, ctx); }, "#A10"); - AssertExtensions.Throws<ValidationException> (() => { + Assert.Throws<ValidationException> (() => { Validator.ValidateProperty ("fail", ctx); }, "#A11"); - AssertExtensions.Throws<ValidationException> (() => { + Assert.Throws<ValidationException> (() => { Validator.ValidateProperty ("f", ctx); }, "#A12"); @@ -900,7 +899,7 @@ namespace MonoTests.System.ComponentModel.DataAnnotations Assert.Fail ("#A1 (exception {0} thrown: {1})", ex.GetType (), ex.Message); } - AssertExtensions.Throws<ArgumentNullException> (() => { + Assert.Throws<ArgumentNullException> (() => { Validator.ValidateValue ("dummy", null, attributes); }, "#A2"); @@ -910,7 +909,7 @@ namespace MonoTests.System.ComponentModel.DataAnnotations Assert.Fail ("#A3 (exception {0} thrown: {1})", ex.GetType (), ex.Message); } - AssertExtensions.Throws<ArgumentNullException> (() => { + Assert.Throws<ArgumentNullException> (() => { Validator.ValidateValue ("dummy", ctx, null); }, "#A4"); } @@ -928,14 +927,14 @@ namespace MonoTests.System.ComponentModel.DataAnnotations new RequiredAttributePoker (log) }; - AssertExtensions.Throws<ValidationException> (() => { + Assert.Throws<ValidationException> (() => { Validator.ValidateValue (null, ctx, attributes); }, "#A1-1"); Assert.AreEqual (1, log.Count, "#A1-2"); Assert.IsTrue (log[0].StartsWith ("RequiredAttributePoker.IsValid (object)"), "#A1-3"); log.Clear (); - AssertExtensions.Throws<InvalidCastException> (() => { + Assert.Throws<InvalidCastException> (() => { // Thrown by StringValidatorAttribute Validator.ValidateValue (1234, ctx, attributes); }, "#A2-1");; @@ -946,7 +945,7 @@ namespace MonoTests.System.ComponentModel.DataAnnotations attributes.Add (new CustomValidationAttribute (typeof (ValidatorTest), "ValueValidationMethod")); attributes.Add (new CustomValidationAttribute (typeof (ValidatorTest), "ValueValidationMethod")); - AssertExtensions.Throws<ValidationException> (() => { + Assert.Throws<ValidationException> (() => { Validator.ValidateValue ("test", ctx, attributes); }, "#A3-1"); Assert.AreEqual (2, log.Count, "#A3-2"); @@ -956,7 +955,7 @@ namespace MonoTests.System.ComponentModel.DataAnnotations attributes.RemoveAt (2); attributes.RemoveAt (2); - AssertExtensions.Throws<ArgumentNullException> (() => { + Assert.Throws<ArgumentNullException> (() => { Validator.ValidateValue ("dummy", null, attributes); }, "#B1"); @@ -966,7 +965,7 @@ namespace MonoTests.System.ComponentModel.DataAnnotations Assert.Fail ("#B2 (exception {0} thrown: {1})", ex.GetType (), ex.Message); } - AssertExtensions.Throws<ArgumentNullException> (() => { + Assert.Throws<ArgumentNullException> (() => { Validator.ValidateValue ("dummy", ctx, null); }, "#B3"); } |