Imported Upstream version 4.3.2.467

Former-commit-id: 9c2cb47f45fa221e661ab616387c9cda183f283d
This commit is contained in:
Xamarin Public Jenkins
2016-02-22 11:00:01 -05:00
parent f302175246
commit f3e3aab35a
4097 changed files with 122406 additions and 82300 deletions

View File

@ -2,58 +2,58 @@ namespace System.ComponentModel.DataAnnotations.Resources
{
static class DataAnnotationsResources
{
public const string ArgumentIsNullOrWhitespace = "ArgumentIsNullOrWhitespace";
public const string AssociatedMetadataTypeTypeDescriptor_MetadataTypeContainsUnknownProperties = "AssociatedMetadataTypeTypeDescriptor_MetadataTypeContainsUnknownProperties";
public const string AttributeStore_Unknown_Property = "AttributeStore_Unknown_Property";
public const string Common_PropertyNotFound = "Common_PropertyNotFound";
public const string CompareAttribute_MustMatch = "CompareAttribute_MustMatch";
public const string CompareAttribute_UnknownProperty = "CompareAttribute_UnknownProperty";
public const string CreditCardAttribute_Invalid = "CreditCardAttribute_Invalid";
public const string CustomValidationAttribute_Method_Must_Return_ValidationResult = "CustomValidationAttribute_Method_Must_Return_ValidationResult";
public const string CustomValidationAttribute_Method_Not_Found = "CustomValidationAttribute_Method_Not_Found";
public const string CustomValidationAttribute_Method_Required = "CustomValidationAttribute_Method_Required";
public const string CustomValidationAttribute_Method_Signature = "CustomValidationAttribute_Method_Signature";
public const string CustomValidationAttribute_Type_Conversion_Failed = "CustomValidationAttribute_Type_Conversion_Failed";
public const string CustomValidationAttribute_Type_Must_Be_Public = "CustomValidationAttribute_Type_Must_Be_Public";
public const string ArgumentIsNullOrWhitespace = "The argument '{0}' cannot be null, empty or contain only white space.";
public const string AssociatedMetadataTypeTypeDescriptor_MetadataTypeContainsUnknownProperties = "The associated metadata type for type '{0}' contains the following unknown properties or fields: {1}. Please make sure that the names of these members match the names of the properties on the main type.";
public const string AttributeStore_Unknown_Property = "The type '{0}' does not contain a public property named '{1}'.";
public const string Common_PropertyNotFound = "The property {0}.{1} could not be found.";
public const string CompareAttribute_MustMatch = "'{0}' and '{1}' do not match.";
public const string CompareAttribute_UnknownProperty = "Could not find a property named {0}.";
public const string CreditCardAttribute_Invalid = "The {0} field is not a valid credit card number.";
public const string CustomValidationAttribute_Method_Must_Return_ValidationResult = "The CustomValidationAttribute method '{0}' in type '{1}' must return System.ComponentModel.DataAnnotations.ValidationResult. Use System.ComponentModel.DataAnnotations.ValidationResult.Success to represent success.";
public const string CustomValidationAttribute_Method_Not_Found = "The CustomValidationAttribute method '{0}' does not exist in type '{1}' or is not public and static.";
public const string CustomValidationAttribute_Method_Required = "The CustomValidationAttribute.Method was not specified.";
public const string CustomValidationAttribute_Method_Signature = "The CustomValidationAttribute method '{0}' in type '{1}' must match the expected signature: public static ValidationResult {0}(object value, ValidationContext context). The value can be strongly typed. The ValidationContext parameter is optional.";
public const string CustomValidationAttribute_Type_Conversion_Failed = "Could not convert the value of type '{0}' to '{1}' as expected by method {2}.{3}.";
public const string CustomValidationAttribute_Type_Must_Be_Public = "The custom validation type '{0}' must be public.";
public const string CustomValidationAttribute_ValidationError = "{0} is not valid.";
public const string CustomValidationAttribute_ValidatorType_Required = "CustomValidationAttribute_ValidatorType_Required";
public const string DataTypeAttribute_EmptyDataTypeString = "DataTypeAttribute_EmptyDataTypeString";
public const string CustomValidationAttribute_ValidatorType_Required = "The CustomValidationAttribute.ValidatorType was not specified.";
public const string DataTypeAttribute_EmptyDataTypeString = "The custom DataType string cannot be null or empty.";
public const string DisplayAttribute_PropertyNotSet = "The {0} property has not been set. Use the {1} method to get the value.";
public const string EmailAddressAttribute_Invalid = "EmailAddressAttribute_Invalid";
public const string EnumDataTypeAttribute_TypeCannotBeNull = "EnumDataTypeAttribute_TypeCannotBeNull";
public const string EnumDataTypeAttribute_TypeNeedsToBeAnEnum = "EnumDataTypeAttribute_TypeNeedsToBeAnEnum";
public const string FileExtensionsAttribute_Invalid = "FileExtensionsAttribute_Invalid";
public const string LocalizableString_LocalizationFailed = "Cannot retrieve property '{0}' because localization failed. Type '{1}' is not public or does not contain a public static string property with the name '{2}'.";
public const string MaxLengthAttribute_InvalidMaxLength = "MaxLengthAttribute_InvalidMaxLength";
public const string MaxLengthAttribute_ValidationError = "MaxLengthAttribute_ValidationError";
public const string MetadataTypeAttribute_TypeCannotBeNull = "MetadataTypeAttribute_TypeCannotBeNull";
public const string MinLengthAttribute_InvalidMinLength = "MinLengthAttribute_InvalidMinLength";
public const string MinLengthAttribute_ValidationError = "MinLengthAttribute_ValidationError";
public const string PhoneAttribute_Invalid = "PhoneAttribute_Invalid";
public const string RangeAttribute_ArbitraryTypeNotIComparable = "RangeAttribute_ArbitraryTypeNotIComparable";
public const string RangeAttribute_MinGreaterThanMax = "RangeAttribute_MinGreaterThanMax";
public const string RangeAttribute_Must_Set_Min_And_Max = "RangeAttribute_Must_Set_Min_And_Max";
public const string RangeAttribute_Must_Set_Operand_Type = "RangeAttribute_Must_Set_Operand_Type";
public const string EmailAddressAttribute_Invalid = "The {0} field is not a valid e-mail address.";
public const string EnumDataTypeAttribute_TypeCannotBeNull = "The type provided for EnumDataTypeAttribute cannot be null.";
public const string EnumDataTypeAttribute_TypeNeedsToBeAnEnum = "The type '{0}' needs to represent an enumeration type.";
public const string FileExtensionsAttribute_Invalid = "The {0} field only accepts files with the following extensions: {1}";
public const string LocalizableString_LocalizationFailed = "Cannot retrieve property '{0}' because localization failed. Type '{1}' is not public or does not contain a public static string property with the name '{2}'.";
public const string MaxLengthAttribute_InvalidMaxLength = "MaxLengthAttribute must have a Length value that is greater than zero. Use MaxLength() without parameters to indicate that the string or array can have the maximum allowable length.";
public const string MaxLengthAttribute_ValidationError = "The field {0} must be a string or array type with a maximum length of '{1}'.";
public const string MetadataTypeAttribute_TypeCannotBeNull = "MetadataClassType cannot be null.";
public const string MinLengthAttribute_InvalidMinLength = "MinLengthAttribute must have a Length value that is zero or greater.";
public const string MinLengthAttribute_ValidationError = "The field {0} must be a string or array type with a minimum length of '{1}'.";
public const string PhoneAttribute_Invalid = "The {0} field is not a valid phone number.";
public const string RangeAttribute_ArbitraryTypeNotIComparable = "The type {0} must implement {1}.";
public const string RangeAttribute_MinGreaterThanMax = "The maximum value '{0}' must be greater than or equal to the minimum value '{1}'.";
public const string RangeAttribute_Must_Set_Min_And_Max = "The minimum and maximum values must be set.";
public const string RangeAttribute_Must_Set_Operand_Type = "The OperandType must be set when strings are used for minimum and maximum values.";
public const string RangeAttribute_ValidationError = "The field {0} must be between {1} and {2}.";
public const string RegexAttribute_ValidationError = "The field {0} must match the regular expression {1}.";
public const string RegexAttribute_ValidationError = "The field {0} must match the regular expression '{1}'.";
public const string RegularExpressionAttribute_Empty_Pattern = "The pattern must be set to a valid regular expression.";
public const string RequiredAttribute_ValidationError = "RequiredAttribute_ValidationError";
public const string StringLengthAttribute_InvalidMaxLength = "StringLengthAttribute_InvalidMaxLength";
public const string RequiredAttribute_ValidationError = "The {0} field is required.";
public const string StringLengthAttribute_InvalidMaxLength = "The maximum length must be a nonnegative integer.";
public const string StringLengthAttribute_ValidationError = "The field {0} must be a string with a maximum length of {1}.";
public const string StringLengthAttribute_ValidationErrorIncludingMinimum = "StringLengthAttribute_ValidationErrorIncludingMinimum";
public const string UIHintImplementation_ControlParameterKeyIsNotAString = "UIHintImplementation_ControlParameterKeyIsNotAString";
public const string UIHintImplementation_ControlParameterKeyIsNull = "UIHintImplementation_ControlParameterKeyIsNull";
public const string UIHintImplementation_ControlParameterKeyOccursMoreThanOnce = "UIHintImplementation_ControlParameterKeyOccursMoreThanOnce";
public const string UIHintImplementation_NeedEvenNumberOfControlParameters = "UIHintImplementation_NeedEvenNumberOfControlParameters";
public const string UrlAttribute_Invalid = "UrlAttribute_Invalid";
public const string ValidationAttribute_Cannot_Set_ErrorMessage_And_Resource = "ValidationAttribute_Cannot_Set_ErrorMessage_And_Resource";
public const string ValidationAttribute_IsValid_NotImplemented = "ValidationAttribute_IsValid_NotImplemented";
public const string ValidationAttribute_NeedBothResourceTypeAndResourceName = "ValidationAttribute_NeedBothResourceTypeAndResourceName";
public const string ValidationAttribute_ResourcePropertyNotStringType = "ValidationAttribute_ResourcePropertyNotStringType";
public const string ValidationAttribute_ResourceTypeDoesNotHaveProperty = "ValidationAttribute_ResourceTypeDoesNotHaveProperty";
public const string StringLengthAttribute_ValidationErrorIncludingMinimum = "The field {0} must be a string with a minimum length of {2} and a maximum length of {1}.";
public const string UIHintImplementation_ControlParameterKeyIsNotAString = "The key parameter at position {0} with value '{1}' is not a string. Every key control parameter must be a string.";
public const string UIHintImplementation_ControlParameterKeyIsNull = "The key parameter at position {0} is null. Every key control parameter must be a string.";
public const string UIHintImplementation_ControlParameterKeyOccursMoreThanOnce = "The key parameter at position {0} with value '{1}' occurs more than once.";
public const string UIHintImplementation_NeedEvenNumberOfControlParameters = "The number of control parameters must be even.";
public const string UrlAttribute_Invalid = "The {0} field is not a valid fully-qualified http, https, or ftp URL.";
public const string ValidationAttribute_Cannot_Set_ErrorMessage_And_Resource = "Either ErrorMessageString or ErrorMessageResourceName must be set, but not both.";
public const string ValidationAttribute_IsValid_NotImplemented = "IsValid(object value) has not been implemented by this class. The preferred entry point is GetValidationResult() and classes should override IsValid(object value, ValidationContext context).";
public const string ValidationAttribute_NeedBothResourceTypeAndResourceName = "Both ErrorMessageResourceType and ErrorMessageResourceName need to be set on this attribute.";
public const string ValidationAttribute_ResourcePropertyNotStringType = "The property '{0}' on resource type '{1}' is not a string type.";
public const string ValidationAttribute_ResourceTypeDoesNotHaveProperty = "The resource type '{0}' does not have an accessible static property named '{1}'.";
public const string ValidationAttribute_ValidationError = "The field {0} is invalid.";
public const string ValidationContextServiceContainer_ItemAlreadyExists = "ValidationContextServiceContainer_ItemAlreadyExists";
public const string Validator_InstanceMustMatchValidationContextInstance = "Validator_InstanceMustMatchValidationContextInstance";
public const string Validator_Property_Value_Wrong_Type = "Validator_Property_Value_Wrong_Type";
public const string ValidationContextServiceContainer_ItemAlreadyExists = "A service of type '{0}' already exists in the container.";
public const string Validator_InstanceMustMatchValidationContextInstance = "The instance provided must match the ObjectInstance on the ValidationContext supplied.";
public const string Validator_Property_Value_Wrong_Type = "The value for property '{0}' must be of type '{1}'.";
}
}
}

View File

@ -1,5 +1,6 @@
../../build/common/Consts.cs
Assembly/AssemblyInfo.cs
../../../external/referencesource/System.ComponentModel.DataAnnotations/DataAnnotations/AppSettings.cs
../../../external/referencesource/System.ComponentModel.DataAnnotations/DataAnnotations/AssociatedMetadataTypeTypeDescriptionProvider.cs
../../../external/referencesource/System.ComponentModel.DataAnnotations/DataAnnotations/AssociatedMetadataTypeTypeDescriptor.cs
../../../external/referencesource/System.ComponentModel.DataAnnotations/DataAnnotations/AssociationAttribute.cs

View File

@ -35,7 +35,6 @@ using NUnit.Framework;
namespace MonoTests.System.ComponentModel.DataAnnotations
{
#if NET_4_0
[TestFixture]
public class AssociationAttributeTest
{
@ -125,5 +124,4 @@ namespace MonoTests.System.ComponentModel.DataAnnotations
Assert.AreEqual (String.Empty, list [0], "#C4-2");
}
}
#endif
}

View File

@ -8,7 +8,6 @@ using System.Reflection;
namespace MonoTests.System.ComponentModel.DataAnnotations
{
#if NET_4_0
public class AttributeTargetValidation
{
[Display(ResourceType = typeof(GoodResources), Name = "NameKey")]
@ -71,7 +70,7 @@ namespace MonoTests.System.ComponentModel.DataAnnotations
public class DisplayAttributeTests
{
const string property_not_set_message = "The {0} property has not been set. Use the Get{0} method to get the value.";
const string localization_failed_message = "Cannot retrieve property '{0}' because localization failed. Type '{1}' is not public or does not contain a public static string property with the name '{2}'.";
const string localization_failed_message = "Cannot retrieve property '{0}' because localization failed. Type '{1}' is not public or does not contain a public static string property with the name '{2}'.";
[Test]
public void StringProperties_ReturnLiteralValues_Success()
@ -274,5 +273,4 @@ namespace MonoTests.System.ComponentModel.DataAnnotations
Assert.Fail();
}
}
#endif
}

View File

@ -35,7 +35,6 @@ using NUnit.Framework;
namespace MonoTests.System.ComponentModel.DataAnnotations
{
#if NET_4_0
[TestFixture]
public class EnumDataTypeAttributeTest
{
@ -133,5 +132,4 @@ namespace MonoTests.System.ComponentModel.DataAnnotations
Five = 8,
Six = 16
}
#endif
}

View File

@ -5,7 +5,6 @@
// https://silverlight.svn.codeplex.com/svn/Release/Silverlight4/Source/RiaClient.Tests/System.ComponentModel.DataAnnotations/FilterUIHintAttributeTest.cs
#if NET_4_0
using System;
using System.ComponentModel;
@ -90,4 +89,3 @@ namespace MonoTests.System.ComponentModel.DataAnnotations
}
}
#endif

View File

@ -104,26 +104,16 @@ namespace MonoTests.System.ComponentModel.DataAnnotations
Assert.IsNotNull (attr.Minimum, "#A1-1");
Assert.IsNotNull (attr.Maximum, "#A1-2");
#if NET_4_0
Assert.AreEqual (typeof (string), attr.Minimum.GetType (), "#A2-1");
Assert.AreEqual (typeof (string), attr.Maximum.GetType (), "#A2-2");
Assert.AreEqual ("-10", attr.Minimum, "#A3-1");
Assert.AreEqual ("10", attr.Maximum, "#A3-2");
#else
Assert.AreEqual (typeof (int), attr.Minimum.GetType (), "#A2-1");
Assert.AreEqual (typeof (int), attr.Maximum.GetType (), "#A2-2");
Assert.AreEqual (-10, attr.Minimum, "#A3-1");
Assert.AreEqual (10, attr.Maximum, "#A3-2");
#endif
Assert.IsNotNull (attr.OperandType, "#A4-1");
Assert.AreEqual (typeof (int), attr.OperandType, "#A4-2");
}
[Test]
//LAMESPEC: documented to throw
#if !NET_4_0
[ExpectedException (typeof (ArgumentNullException))]
#endif
public void Constructor_Type_String_String_Null_Type ()
{
var attr = new DA.RangeAttribute (null, "-10", "10");
@ -144,7 +134,6 @@ namespace MonoTests.System.ComponentModel.DataAnnotations
attr.IsValid ("zero");
}, "#A1-5");
Assert.IsTrue (attr.IsValid (null), "#A1-6");
#if NET_4_0
attr = new DA.RangeAttribute (typeof (int), "minus ten", "ten");
AssertExtensions.Throws<Exception> (() => {
attr.IsValid ("0");
@ -196,31 +185,6 @@ namespace MonoTests.System.ComponentModel.DataAnnotations
attr.IsValid (12);
Assert.AreEqual (typeof (int), attr.Minimum.GetType (), "#A7-1");
Assert.AreEqual (typeof (int), attr.Maximum.GetType (), "#A7-2");
#else
AssertExtensions.Throws<Exception> (() => {
attr = new DA.RangeAttribute (typeof (int), "minus ten", "ten");
}, "#A2");
AssertExtensions.Throws<ArgumentException> (() => {
attr = new DA.RangeAttribute (typeof (RangeAttributeTest), "-10", "10");
}, "#A3");
AssertExtensions.Throws<ArgumentNullException> (() => {
attr = new DA.RangeAttribute (null, "-10", "10");
}, "#A4");
AssertExtensions.Throws<NotSupportedException> (() => {
attr = new DA.RangeAttribute (typeof (int), null, "10");
}, "#A5-1");
AssertExtensions.Throws<NotSupportedException> (() => {
attr = new DA.RangeAttribute (typeof (int), "10", null);
}, "#A5-2");
attr = new DA.RangeAttribute (typeof (int), "-10", "10");
Assert.AreEqual (typeof (int), attr.Minimum.GetType (), "#A6-1");
Assert.AreEqual (typeof (int), attr.Maximum.GetType (), "#A6-2");
#endif
}
[Test]
@ -232,19 +196,10 @@ namespace MonoTests.System.ComponentModel.DataAnnotations
attr.ErrorMessage = "Param 0: {0}";
Assert.AreEqual ("Param 0: MyField", attr.FormatErrorMessage ("MyField"), "#A2-1");
#if !NET_4_0
attr = new DA.RangeAttribute (-10, 10);
#endif
attr.ErrorMessage = "Param 0: {0}; Param 1: {1}";
Assert.AreEqual ("Param 0: MyField; Param 1: -10", attr.FormatErrorMessage ("MyField"), "#A2-2");
#if !NET_4_0
attr = new DA.RangeAttribute (-10, 10);
#endif
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");
#if !NET_4_0
attr = new DA.RangeAttribute (-10, 10);
#endif
attr.ErrorMessage = "Param 0: {0}; Param 1: {1}; Param 2: {2}; Param 3: {3}";
AssertExtensions.Throws<FormatException> (() => {
attr.FormatErrorMessage ("MyField");

View File

@ -56,7 +56,7 @@ namespace MonoTests.System.ComponentModel.DataAnnotations
var rea = new RegularExpressionAttributePoker (@"[A-Za-z]");
Assert.AreEqual (@"[A-Za-z]", rea.Pattern, "Patterns not saved correctly.");
Assert.AreEqual (null, rea.ErrorMessage, "Error message not null when not yet matched.");
Assert.AreEqual ("The field {0} must match the regular expression {1}.", rea.GetErrorMessageString (), "Error message not valid.");
Assert.AreEqual ("The field {0} must match the regular expression '{1}'.", rea.GetErrorMessageString (), "Error message not valid.");
}
[Test]
@ -64,19 +64,13 @@ namespace MonoTests.System.ComponentModel.DataAnnotations
{
var rea = new RegularExpressionAttributePoker (@"[A-Za-z]");
Assert.AreEqual ("The field MyField must match the regular expression [A-Za-z].",
Assert.AreEqual ("The field MyField must match the regular expression '[A-Za-z]'.",
rea.FormatErrorMessage ("MyField"),
"Error message not correctly formatted.");
#if !NET_4_0
rea = new RegularExpressionAttributePoker (@"[A-Za-z]");
#endif
rea.ErrorMessage = "Param 0: {0}";
Assert.AreEqual ("Param 0: MyField", rea.FormatErrorMessage ("MyField"), "Error message not correctly updated.");
#if !NET_4_0
rea = new RegularExpressionAttributePoker (@"[A-Za-z]");
#endif
rea.ErrorMessage = "Param 0: {0}; Param 1: {1}";
Assert.AreEqual ("Param 0: MyField; Param 1: [A-Za-z]", rea.FormatErrorMessage ("MyField"), "Error message not correctly updated.");
Assert.AreEqual ("Param 0: ; Param 1: [A-Za-z]", rea.FormatErrorMessage (null), "Error message fails on null value.");

View File

@ -45,12 +45,9 @@ namespace MonoTests.System.ComponentModel.DataAnnotations
Assert.IsFalse (attr.IsValid (String.Empty), "#A2");
Assert.IsTrue (attr.IsValid ("string"), "#A3");
Assert.IsTrue (attr.IsValid (1), "#A4");
#if NET_4_0
attr.AllowEmptyStrings = true;
Assert.IsTrue (attr.IsValid (String.Empty), "#A5");
#endif
}
#if NET_4_0
[Test]
public void AllowEmptyStrings ()
{
@ -60,6 +57,5 @@ namespace MonoTests.System.ComponentModel.DataAnnotations
attr.AllowEmptyStrings = true;
Assert.IsTrue (attr.AllowEmptyStrings, "#A2");
}
#endif
}
}

View File

@ -58,16 +58,10 @@ namespace MonoTests.System.ComponentModel.DataAnnotations
Assert.AreEqual (10, sla.MaximumLength, "#A1-1");
Assert.AreEqual (null, sla.ErrorMessage, "#A1-2");
Assert.AreEqual ("The field {0} must be a string with a maximum length of {1}.", sla.GetErrorMessageString (), "#A1-3");
#if NET_4_0
Assert.AreEqual (0, sla.MinimumLength, "#A1-4");
sla = new StringLengthAttributePoker (-10);
Assert.AreEqual (-10, sla.MaximumLength, "#B1");
#else
AssertExtensions.Throws<ArgumentOutOfRangeException> (() => {
sla = new StringLengthAttributePoker (-10);
}, "#B1");
#endif
sla = new StringLengthAttributePoker (0);
Assert.AreEqual (0, sla.MaximumLength, "#C1");
}
@ -78,14 +72,8 @@ namespace MonoTests.System.ComponentModel.DataAnnotations
var sla = new StringLengthAttributePoker (10);
Assert.AreEqual ("The field MyField must be a string with a maximum length of 10.", sla.FormatErrorMessage ("MyField"), "#A1-1");
#if !NET_4_0
sla = new StringLengthAttributePoker (10);
#endif
sla.ErrorMessage = "Param 0: {0}";
Assert.AreEqual ("Param 0: MyField", sla.FormatErrorMessage ("MyField"), "#A1-2");
#if !NET_4_0
sla = new StringLengthAttributePoker (10);
#endif
sla.ErrorMessage = "Param 0: {0}; Param 1: {1}";
Assert.AreEqual ("Param 0: MyField; Param 1: 10", sla.FormatErrorMessage ("MyField"), "#A1-2");
Assert.AreEqual ("Param 0: ; Param 1: 10", sla.FormatErrorMessage (null), "#A1-3");
@ -112,7 +100,6 @@ namespace MonoTests.System.ComponentModel.DataAnnotations
Assert.IsTrue (sla.IsValid (null), "#B1-1");
Assert.IsTrue (sla.IsValid (String.Empty), "#B1-2");
Assert.IsFalse (sla.IsValid ("string"), "#B1-3");
#if NET_4_0
sla = new StringLengthAttributePoker (-10);
AssertExtensions.Throws <InvalidOperationException> (() => {
sla.IsValid ("123");
@ -127,7 +114,6 @@ namespace MonoTests.System.ComponentModel.DataAnnotations
sla.MinimumLength = 5;
Assert.IsFalse (sla.IsValid ("123"), "#C2-1");
Assert.IsTrue (sla.IsValid ("12345"), "#C2-2");
#endif
}
}
}

View File

@ -5,7 +5,6 @@
// https://silverlight.svn.codeplex.com/svn/Release/Silverlight4/Source/RiaClient.Tests/System.ComponentModel.DataAnnotations/UIHintAttributeTest.cs
#if NET_4_0
using System;
using System.ComponentModel;
@ -136,4 +135,3 @@ namespace MonoTests.System.ComponentModel.DataAnnotations
}
}
#endif

View File

@ -89,46 +89,11 @@ namespace MonoTests.System.ComponentModel.DataAnnotations
attr.ErrorMessage = "Test";
Assert.AreEqual ("Test", attr.ErrorMessage, "#A2");
#if NET_4_0
attr.ErrorMessage = String.Empty;
Assert.AreEqual (String.Empty, attr.ErrorMessage, "#A3");
attr.ErrorMessage = null;
Assert.IsNull (attr.ErrorMessage, "#A4");
#else
try {
attr.ErrorMessage = String.Empty;
Assert.Fail ("#A3");
} catch (InvalidOperationException) {
// success
}
attr = new ValidateFooAttribute ("Test");
try {
attr.ErrorMessage = null;
Assert.Fail ("#A4");
} catch (ArgumentException) {
// success
}
attr = new ValidateFooAttribute ("Test");
try {
attr.ErrorMessage = String.Empty;
Assert.Fail ("#A4");
} catch (ArgumentException) {
// success
}
attr = new ValidateFooAttribute ();
attr.ErrorMessageResourceName = "ErrorProperty1";
try {
attr.ErrorMessage = "Test Message";
Assert.Fail ("#E1");
} catch (InvalidOperationException) {
// success
}
#endif
}
@ -142,47 +107,12 @@ namespace MonoTests.System.ComponentModel.DataAnnotations
attr.ErrorMessageResourceName = "Test";
Assert.IsNotNull (attr.ErrorMessageResourceName, "#A2-1");
Assert.AreEqual ("Test", attr.ErrorMessageResourceName, "#A2-2");
#if NET_4_0
attr.ErrorMessageResourceName = String.Empty;
Assert.IsNotNull (attr.ErrorMessageResourceName, "#A3-1");
Assert.AreEqual (String.Empty, attr.ErrorMessageResourceName, "#A3-2");
attr.ErrorMessageResourceName = null;
Assert.IsNull (attr.ErrorMessageResourceName, "#A3-1");
#else
try {
attr.ErrorMessageResourceName = String.Empty;
Assert.Fail ("#A3-1");
} catch (InvalidOperationException) {
// success
}
attr = new ValidateFooAttribute ("Test");
try {
attr.ErrorMessageResourceName = String.Empty;
Assert.Fail ("#A3-2");
} catch (ArgumentException) {
// success
}
attr = new ValidateFooAttribute ("Test");
try {
attr.ErrorMessageResourceName = null;
Assert.Fail ("#A3-3");
} catch (ArgumentException) {
// success
}
attr = new ValidateFooAttribute ();
attr.ErrorMessageResourceType = typeof (FooErrorMessageProvider);
try {
attr.ErrorMessageResourceName = "NoSuchProperty";
Assert.Fail ("#A3-4");
} catch (InvalidOperationException) {
// success
}
#endif
}
[Test]
@ -195,17 +125,6 @@ namespace MonoTests.System.ComponentModel.DataAnnotations
attr.ErrorMessageResourceType = typeof (FooErrorMessageProvider);
Assert.IsNotNull (attr.ErrorMessageResourceType, "#A2-1");
Assert.AreEqual (typeof (FooErrorMessageProvider), attr.ErrorMessageResourceType, "#A2-2");
#if !NET_4_0
attr = new ValidateFooAttribute ();
attr.ErrorMessageResourceName = "NoSuchProperty";
try {
attr.ErrorMessageResourceType = typeof (FooErrorMessageProvider);
Assert.Fail ("#A3");
} catch (InvalidOperationException) {
// success
}
#endif
}
[Test]
@ -224,7 +143,6 @@ namespace MonoTests.System.ComponentModel.DataAnnotations
} catch (InvalidOperationException) {
// success
}
#if NET_4_0
attr = new ValidateFooAttribute ();
attr.ErrorMessageResourceName = String.Empty;
try {
@ -324,7 +242,6 @@ namespace MonoTests.System.ComponentModel.DataAnnotations
} catch (InvalidOperationException) {
// success
}
#endif
attr = new ValidateFooAttribute ();
attr.ErrorMessageResourceName = "ErrorProperty1";
@ -341,7 +258,6 @@ namespace MonoTests.System.ComponentModel.DataAnnotations
attr.ErrorMessageResourceType = typeof (FooErrorMessageProvider);
Assert.IsNotNull (attr.GetErrorMessageString (), "#D1-3");
Assert.AreEqual ("Error Message 1", attr.GetErrorMessageString (), "#D1-4");
#if NET_4_0
attr.ErrorMessage = "Test Message";
try {
attr.GetErrorMessageString ();
@ -349,7 +265,6 @@ namespace MonoTests.System.ComponentModel.DataAnnotations
} catch (InvalidOperationException) {
// success
}
#endif
}
[Test]
@ -363,31 +278,20 @@ namespace MonoTests.System.ComponentModel.DataAnnotations
attr.ErrorMessage = "Test: {0}";
Assert.IsNotNull (attr.FormatErrorMessage ("SomeField"), "#A2-1");
Assert.AreEqual ("Test: SomeField", attr.FormatErrorMessage ("SomeField"), "#A2-2");
#if !NET_4_0
attr = new ValidateFooAttribute ();
#else
attr.ErrorMessage = null;
#endif
attr.ErrorMessageResourceName = "ErrorProperty1";
attr.ErrorMessageResourceType = typeof (FooErrorMessageProvider);
Assert.IsNotNull (attr.FormatErrorMessage ("SomeField"), "#B1-1");
Assert.AreEqual ("Error Message 1", attr.FormatErrorMessage ("SomeField"), "#B1-2");
#if !NET_4_0
attr = new ValidateFooAttribute ();
#endif
attr.ErrorMessageResourceName = "ErrorProperty6";
attr.ErrorMessageResourceType = typeof (FooErrorMessageProvider);
Assert.IsNotNull (attr.FormatErrorMessage ("SomeField"), "#B2-1");
Assert.AreEqual ("Error Message 6: SomeField", attr.FormatErrorMessage ("SomeField"), "#B2-2");
#if !NET_4_0
attr = new ValidateFooAttribute ();
#endif
attr.ErrorMessageResourceName = "ErrorProperty6";
attr.ErrorMessageResourceType = typeof (FooErrorMessageProvider);
Assert.IsNotNull (attr.FormatErrorMessage ("SomeField"), "#B3-1");
Assert.AreEqual ("Error Message 6: ", attr.FormatErrorMessage (null), "#B3-2");
}
#if NET_4_0
[Test]
public void GetValidationResult ()
{
@ -498,7 +402,7 @@ namespace MonoTests.System.ComponentModel.DataAnnotations
}
[Test]
public void IsValid_Object_ValidationContext_CrossCallsWithNIEX ()
public void IsValid_Object_No_User_EntryPoint ()
{
var attr = new ValidateSomethingAttribute ();
@ -515,23 +419,8 @@ namespace MonoTests.System.ComponentModel.DataAnnotations
// at MonoTests.System.ComponentModel.DataAnnotations.ValidationAttributeTest.IsValid_Object_ValidationContext_02() in C:\Users\grendel\Documents\Visual Studio 2010\Projects\System.Web.Test\System.Web.Test\System.ComponentModel.DataAnnotations\ValidationAttributeTest.cs:line 514
attr.IsValid ("stuff");
}, "#A1");
AssertExtensions.Throws<NotImplementedException> (() => {
// And this one is thrown from the IsValid (object) overload!
//
// MonoTests.System.ComponentModel.DataAnnotations.ValidationAttributeTest.IsValid_Object_ValidationContext_CrossCallsWithNIEX:
// System.NotImplementedException : IsValid(object value) has not been implemented by this class. The preferred entry point is GetValidationResult() and classes should override IsValid(object value, ValidationContext context).
//
// at System.ComponentModel.DataAnnotations.ValidationAttribute.IsValid(Object value)
// at MonoTests.System.ComponentModel.DataAnnotations.ValidateSomethingAttribute.IsValid(Object value, ValidationContext validationContext) in C:\Users\grendel\Documents\Visual Studio 2010\Projects\System.Web.Test\System.Web.Test\System.ComponentModel.DataAnnotations\ValidationAttributeTest.cs:line 660
// at System.ComponentModel.DataAnnotations.ValidationAttribute.IsValid(Object value)
// at MonoTests.System.ComponentModel.DataAnnotations.ValidateSomethingAttribute.IsValid(Object value, ValidationContext validationContext) in C:\Users\grendel\Documents\Visual Studio 2010\Projects\System.Web.Test\System.Web.Test\System.ComponentModel.DataAnnotations\ValidationAttributeTest.cs:line 660
// at MonoTests.System.ComponentModel.DataAnnotations.ValidateSomethingAttribute.CallIsValid(Object value, ValidationContext validationContext) in C:\Users\grendel\Documents\Visual Studio 2010\Projects\System.Web.Test\System.Web.Test\System.ComponentModel.DataAnnotations\ValidationAttributeTest.cs:line 667
// at MonoTests.System.ComponentModel.DataAnnotations.ValidationAttributeTest.IsValid_Object_ValidationContext_CrossCallsWithNIEX() in C:\Users\grendel\Documents\Visual Studio 2010\Projects\System.Web.Test\System.Web.Test\System.ComponentModel.DataAnnotations\ValidationAttributeTest.cs:line 530
attr.CallIsValid ("stuff", null);
}, "#A2");
}
[Test]
public void Validate_Object_ValidationContext ()
{
@ -556,7 +445,6 @@ namespace MonoTests.System.ComponentModel.DataAnnotations
Assert.AreEqual ("bool IsValid (object value)", attr.Calls [1], "#A2-3");
Assert.AreEqual ("string FormatErrorMessage (string name)", attr.Calls [2], "#A2-4");
}
#endif
[Test]
public void Validate_Object_String ()
{
@ -593,12 +481,6 @@ namespace MonoTests.System.ComponentModel.DataAnnotations
{
return ErrorMessageString;
}
#if !NET_4_0
public override bool IsValid (object value)
{
return value != null;
}
#endif
}
class ValidateBarAttribute : ValidateFooAttribute
@ -613,7 +495,6 @@ namespace MonoTests.System.ComponentModel.DataAnnotations
{
return value != null;
}
#if NET_4_0
protected override ValidationResult IsValid (object value, ValidationContext validationContext)
{
if (!IsValid (value))
@ -625,7 +506,6 @@ namespace MonoTests.System.ComponentModel.DataAnnotations
{
return base.IsValid (value, validationContext);
}
#endif
}
class ValidateBazAttribute : ValidateBarAttribute
@ -637,40 +517,22 @@ namespace MonoTests.System.ComponentModel.DataAnnotations
Calls.Add ("bool IsValid (object value)");
return base.IsValid (value);
}
#if NET_4_0
protected override ValidationResult IsValid (object value, ValidationContext validationContext)
{
Calls.Add ("ValidationResult IsValid (object value, ValidationContext validationContext)");
return base.IsValid (value, validationContext);
}
#endif
public override string FormatErrorMessage (string name)
{
Calls.Add ("string FormatErrorMessage (string name)");
return base.FormatErrorMessage (name);
}
}
#if NET_4_0
class ValidateSomethingAttribute : ValidationAttribute
{
public override bool IsValid (object value)
{
return base.IsValid (value, null) == ValidationResult.Success;
}
protected override ValidationResult IsValid (object value, ValidationContext validationContext)
{
if (base.IsValid (value))
return ValidationResult.Success;
return new ValidationResult ("failed to validate in base class");
}
public ValidationResult CallIsValid (object value, ValidationContext validationContext)
{
return IsValid (value, validationContext);
}
}
#endif
class FooErrorMessageProvider
{
public static string ErrorProperty1

View File

@ -35,7 +35,6 @@ using NUnit.Framework;
namespace MonoTests.System.ComponentModel.DataAnnotations
{
#if NET_4_0
[TestFixture]
public class ValidationContextTest
{
@ -238,5 +237,4 @@ namespace MonoTests.System.ComponentModel.DataAnnotations
return null;
}
}
#endif
}

View File

@ -35,7 +35,6 @@ using NUnit.Framework;
namespace MonoTests.System.ComponentModel.DataAnnotations
{
#if NET_4_0
[TestFixture]
public class ValidationResultTest
{
@ -93,5 +92,4 @@ namespace MonoTests.System.ComponentModel.DataAnnotations
Assert.IsNull (success, "#A1");
}
}
#endif
}

View File

@ -33,7 +33,6 @@ using MonoTests.Common;
namespace MonoTests.System.ComponentModel.DataAnnotations
{
#if NET_4_0
[TestFixture]
public class ValidatorTest
{
@ -1233,5 +1232,4 @@ namespace MonoTests.System.ComponentModel.DataAnnotations
}
}
}
#endif
}