User: jonathon.rossi
Date: 2009/11/29 05:09 AM
Added:
/Components/Pagination/trunk/src/Castle.Components.Pagination.Tests/
ComIssue102.cs
Modified:
/Components/Pagination/trunk/src/Castle.Components.Pagination.Tests/
Castle.Components.Pagination.Tests-vs2008.csproj
/Components/Pagination/trunk/src/Castle.Components.Pagination/
GenericPage.cs, Page.cs
Log:
Applied Daniel Hâlbling's patch fixing COMP-ISSUE-102 - GenericPage doesn't
behave gracefully when PageSize = 0.
Also added exception to the xml documentation of the constructors and
converted spaces to tabs.
File Changes:
Directory: /Components/Pagination/trunk/src/Castle.Components.Pagination/
=========================================================================
File [modified]: GenericPage.cs
Delta lines: +3 -0
===================================================================
--- Components/Pagination/trunk/src/Castle.Components.Pagination/Page.cs
2009-11-29 10:52:24 UTC (rev 6372)
+++ Components/Pagination/trunk/src/Castle.Components.Pagination/Page.cs
2009-11-29 12:09:51 UTC (rev 6373)
@@ -34,8 +34,11 @@
/// <param name="currentPageIndex">The desired page
index</param>
/// <param name="pageSize">The desired page size</param>
/// <param name="total">The total of items in the data
source.</param>
+ /// <exception cref="ArgumentOutOfRangeException">Thrown when
<paramref name="pageSize"/> is less than 1.</exception>
protected Page(int currentPageIndex, int pageSize, int total)
{
+ if (pageSize <= 0) throw new
ArgumentOutOfRangeException("pageSize", "pageSize cannot be less than 1.");
+
startIndex = (pageSize * currentPageIndex) - pageSize;
endIndex = Math.Min(startIndex + pageSize, total);
File [modified]: Page.cs
Delta lines: +1 -0
===================================================================
---
Components/Pagination/trunk/src/Castle.Components.Pagination.Tests/Castle.Components.Pagination.Tests-vs2008.csproj
2009-11-29 10:52:24 UTC (rev 6372)
+++
Components/Pagination/trunk/src/Castle.Components.Pagination.Tests/Castle.Components.Pagination.Tests-vs2008.csproj
2009-11-29 12:09:51 UTC (rev 6373)
@@ -51,6 +51,7 @@
<ItemGroup>
<Compile Include="AssemblyInfo.cs" />
<Compile Include="BasePaginatedPageTestCase.cs" />
+ <Compile Include="ComIssue102.cs" />
</ItemGroup>
<ItemGroup>
Directory: /Components/Pagination/trunk/src/Castle.Components.Pagination.Tests/
===============================================================================
File [modified]: Castle.Components.Pagination.Tests-vs2008.csproj
Delta lines: +43 -0
===================================================================
---
Components/Pagination/trunk/src/Castle.Components.Pagination.Tests/ComIssue102.cs
(rev 0)
+++
Components/Pagination/trunk/src/Castle.Components.Pagination.Tests/ComIssue102.cs
2009-11-29 12:09:51 UTC (rev 6373)
@@ -0,0 +1,43 @@
+// Copyright 2004-2009 Castle Project - http://www.castleproject.org/
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+namespace Castle.Components.Pagination.Tests
+{
+ using System;
+ using NUnit.Framework;
+
+ [TestFixture]
+ public class ComIssue102
+ {
+ [Test]
+ public void
GenericPageCtor_PageSizeZero_ThrowsArgumentOutOfRangeException()
+ {
+ int[] ints = { 1, 2, 3 };
+ Assert.Throws(typeof(ArgumentOutOfRangeException), () =>
+ {
+ var page = new GenericPage<int>(ints, 0, 0);
+ });
+ }
+
+ [Test]
+ public void
PageCtor_PageSizeZero_ThrowsArgumentOutOfRangeException()
+ {
+ int[] ints = { 1, 2, 3 };
+ Assert.Throws(typeof(ArgumentOutOfRangeException), () =>
+ {
+ var page = new Page(ints, 0, 0);
+ });
+ }
+ }
+}
File [added]: ComIssue102.cs
Delta lines: +0 -0
===================================================================
--
You received this message because you are subscribed to the Google Groups
"Castle Project Commits" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/castle-project-commits?hl=en.