diff options
author | youssefm <youssefm@microsoft.com> | 2012-10-13 01:44:01 +0400 |
---|---|---|
committer | youssefm <youssefm@microsoft.com> | 2012-10-13 01:44:01 +0400 |
commit | fb7632d7eaf7121c58ef8e43371187de69dcfc83 (patch) | |
tree | c04396833caa771ea654d503054b63b7dcbb472c | |
parent | fc327be7e55cb283c8623caab5dabc85b74c35c7 (diff) |
[OData] Changing Error.Argument to Error.ArgumentMustBeGreaterThanOrEqualTo for non-positive result limits
5 files changed, 7 insertions, 15 deletions
diff --git a/src/System.Web.Http.OData/HttpConfigurationExtensions.cs b/src/System.Web.Http.OData/HttpConfigurationExtensions.cs index 61215b8e..19617d1f 100644 --- a/src/System.Web.Http.OData/HttpConfigurationExtensions.cs +++ b/src/System.Web.Http.OData/HttpConfigurationExtensions.cs @@ -200,7 +200,7 @@ namespace System.Web.Http } if (resultLimit <= 0) { - throw Error.Argument("resultLimit", SRResources.ResultLimitMustBePositive); + throw Error.ArgumentMustBeGreaterThanOrEqualTo("resultLimit", resultLimit, 1); } configuration.Services.Add(typeof(IFilterProvider), new QueryableFilterProvider() { ResultLimit = resultLimit }); diff --git a/src/System.Web.Http.OData/Properties/SRResources.Designer.cs b/src/System.Web.Http.OData/Properties/SRResources.Designer.cs index 65cb751f..9991f943 100644 --- a/src/System.Web.Http.OData/Properties/SRResources.Designer.cs +++ b/src/System.Web.Http.OData/Properties/SRResources.Designer.cs @@ -916,15 +916,6 @@ namespace System.Web.Http.OData.Properties { } /// <summary> - /// Looks up a localized string similar to The result limit must be a positive number.. - /// </summary> - internal static string ResultLimitMustBePositive { - get { - return ResourceManager.GetString("ResultLimitMustBePositive", resourceCulture); - } - } - - /// <summary> /// Looks up a localized string similar to Could not find the target entity type for the navigation property '{0}' on entity type '{1}'.. /// </summary> internal static string TargetEntityTypeMissing { diff --git a/src/System.Web.Http.OData/Properties/SRResources.resx b/src/System.Web.Http.OData/Properties/SRResources.resx index af33bbd8..3dc8e91a 100644 --- a/src/System.Web.Http.OData/Properties/SRResources.resx +++ b/src/System.Web.Http.OData/Properties/SRResources.resx @@ -414,9 +414,6 @@ <data name="NoODataMediaTypeFormatterFound" xml:space="preserve"> <value>The ODataParameterBindingAttribute requires that an ODataMediaTypeFormatter be registered with the HttpConfiguration.</value> </data> - <data name="ResultLimitMustBePositive" xml:space="preserve"> - <value>The result limit must be a positive number.</value> - </data> <data name="ValueIsInvalid" xml:space="preserve"> <value>The value '{0}' is invalid. {1}</value> </data> diff --git a/src/System.Web.Http.OData/QueryableAttribute.cs b/src/System.Web.Http.OData/QueryableAttribute.cs index c3bec8e4..ed4f9e66 100644 --- a/src/System.Web.Http.OData/QueryableAttribute.cs +++ b/src/System.Web.Http.OData/QueryableAttribute.cs @@ -80,7 +80,7 @@ namespace System.Web.Http { if (value <= 0) { - throw Error.Argument(SRResources.ResultLimitMustBePositive); + throw Error.ArgumentMustBeGreaterThanOrEqualTo("value", value, 1); } _resultLimit = value; } diff --git a/test/System.Web.Http.OData.Test/HttpConfigurationExtensionTests.cs b/test/System.Web.Http.OData.Test/HttpConfigurationExtensionTests.cs index 9a2e0157..53f24568 100644 --- a/test/System.Web.Http.OData.Test/HttpConfigurationExtensionTests.cs +++ b/test/System.Web.Http.OData.Test/HttpConfigurationExtensionTests.cs @@ -160,7 +160,11 @@ namespace System.Web.Http.OData { HttpConfiguration configuration = new HttpConfiguration(); - Assert.Throws<ArgumentException>(() => configuration.EnableQuerySupport(resultLimit), "The result limit must be a positive number.\r\nParameter name: resultLimit"); + Assert.Throws<ArgumentOutOfRangeException>( + () => configuration.EnableQuerySupport(resultLimit), + String.Format( + "Value must be greater than or equal to 1.\r\nParameter name: resultLimit\r\nActual value was {0}.", + resultLimit)); } [Fact] |