User: jonathon.rossi
Date: 2009/11/29 05:27 AM
Modified:
/Components/Pagination/trunk/src/Castle.Components.Pagination.Tests/
BasePaginatedPageTestCase.cs
/Components/Pagination/trunk/src/Castle.Components.Pagination/
AbstractPage.cs, GenericCustomPage.cs, GenericPage.cs, IPaginatedPage.cs,
Page.cs, PaginationSupport.cs
Log:
Quick tidy up of indentation and xml comments.
File Changes:
Directory: /Components/Pagination/trunk/src/Castle.Components.Pagination/
=========================================================================
File [modified]: AbstractPage.cs
Delta lines: +5 -8
===================================================================
---
Components/Pagination/trunk/src/Castle.Components.Pagination/GenericCustomPage.cs
2009-11-29 12:09:51 UTC (rev 6373)
+++
Components/Pagination/trunk/src/Castle.Components.Pagination/GenericCustomPage.cs
2009-11-29 12:27:46 UTC (rev 6374)
@@ -18,8 +18,7 @@
using System.Collections.Generic;
/// <summary>
- /// Represents the sliced data and offers
- /// a few read only properties to create a pagination bar.
+ /// Represents the sliced data and offers a few read only properties to
create a pagination bar.
/// </summary>
[Serializable]
public class GenericCustomPage<T> : AbstractPage<T>, IEnumerable<T>
@@ -27,10 +26,10 @@
private readonly IEnumerable<T> sourceList;
/// <summary>
- /// Initializes a new instance of the <see
cref="GenericCustomPage<T>"/> class.
+ /// Initializes a new instance of the <see
cref="GenericCustomPage{T}"/> class.
/// </summary>
/// <param name="list">The list.</param>
- /// <param name="curPage">The cur page.</param>
+ /// <param name="curPage">The current page.</param>
/// <param name="pageSize">Size of the page.</param>
/// <param name="total">The total.</param>
public GenericCustomPage(IEnumerable<T> list, int curPage, int
pageSize, int total)
@@ -44,8 +43,7 @@
}
/// <summary>
- /// Returns a enumerator for the contents
- /// of this page only (not the whole set)
+ /// Returns a enumerator for the contents of this page only
(not the whole set).
/// </summary>
/// <returns>Enumerator instance</returns>
protected override IEnumerator<T>
GetGenericEnumeratorImplementation()
@@ -60,7 +58,7 @@
/// Returns an enumerator that iterates through the collection.
/// </summary>
/// <returns>
- /// <see
cref="T:System.Collections.Generic.IEnumerator`1"></see> that can be used to
iterate through the collection.
+ /// <see cref="IEnumerator{T}"/> that can be used to iterate
through the collection.
/// </returns>
IEnumerator<T> IEnumerable<T>.GetEnumerator()
{
@@ -70,7 +68,6 @@
}
}
-
protected override T GetGenericItemAtIndex(int itemIndex)
{
File [modified]: GenericCustomPage.cs
Delta lines: +4 -7
===================================================================
--- Components/Pagination/trunk/src/Castle.Components.Pagination/GenericPage.cs
2009-11-29 12:09:51 UTC (rev 6373)
+++ Components/Pagination/trunk/src/Castle.Components.Pagination/GenericPage.cs
2009-11-29 12:27:46 UTC (rev 6374)
@@ -19,8 +19,7 @@
using System.Collections.Generic;
/// <summary>
- /// Represents the sliced data and offers
- /// a few read only properties to create a pagination bar.
+ /// Represents the sliced data and offers a few read-only properties to
create a pagination bar.
/// </summary>
[Serializable]
public class GenericPage<T> : AbstractPage<T>
@@ -29,10 +28,10 @@
private readonly ICollection<T> sourceList;
/// <summary>
- /// Initializes a new instance of the <see
cref="GenericPage<T>"/> class.
+ /// Initializes a new instance of the <see
cref="GenericPage{T}"/> class.
/// </summary>
/// <param name="list">The list.</param>
- /// <param name="curPage">The cur page.</param>
+ /// <param name="curPage">The current page.</param>
/// <param name="pageSize">Size of the page.</param>
/// <exception cref="ArgumentOutOfRangeException">Thrown when
<paramref name="pageSize"/> is less than 1.</exception>
public GenericPage(ICollection<T> list, int curPage, int
pageSize)
@@ -49,8 +48,7 @@
}
/// <summary>
- /// Returns a enumerator for the contents
- /// of this page only (not the whole set)
+ /// Returns a enumerator for the contents of this page only
(not the whole set).
/// </summary>
/// <returns>Enumerator instance</returns>
protected override IEnumerator<T>
GetGenericEnumeratorImplementation()
@@ -96,7 +94,6 @@
return new List<T>(sourceList)[itemIndex];
}
-
protected override object GetItemAtIndex(int itemIndex)
{
File [modified]: GenericPage.cs
Delta lines: +7 -8
===================================================================
---
Components/Pagination/trunk/src/Castle.Components.Pagination/IPaginatedPage.cs
2009-11-29 12:09:51 UTC (rev 6373)
+++
Components/Pagination/trunk/src/Castle.Components.Pagination/IPaginatedPage.cs
2009-11-29 12:27:46 UTC (rev 6374)
@@ -15,14 +15,15 @@
namespace Castle.Components.Pagination
{
using System.Collections;
+
/// <summary>
- /// Represents a page of a bigger set
+ /// Represents a page of a bigger set.
/// </summary>
/// <remarks>
- /// all indexes are one based
+ /// All indexes are one based.
/// </remarks>
- public interface IPaginatedPage : IEnumerable {
-
+ public interface IPaginatedPage : IEnumerable
+ {
#region *PageIndex
/// <summary>
/// The index this page represents
@@ -78,10 +79,8 @@
/// <summary>
/// Checks whether the specified page exists.
/// Useful for Google-like pagination.
- ///
/// </summary>
/// <returns>true if pageNumber is >= FirstPageIndex</returns>
- /// <returns></returns>
bool HasPage(int pageNumber);
#endregion
@@ -110,8 +109,8 @@
/// Generic specialization of <see cref="IPaginatedPage"/>
/// </summary>
/// <typeparam name="T"></typeparam>
- public interface IPaginatedPage<T> : IPaginatedPage,
System.Collections.Generic.IEnumerable<T> {
-
+ public interface IPaginatedPage<T> : IPaginatedPage,
System.Collections.Generic.IEnumerable<T>
+ {
/// <summary>
/// Retrieve the first item on current page
File [modified]: IPaginatedPage.cs
Delta lines: +2 -4
===================================================================
--- Components/Pagination/trunk/src/Castle.Components.Pagination/Page.cs
2009-11-29 12:09:51 UTC (rev 6373)
+++ Components/Pagination/trunk/src/Castle.Components.Pagination/Page.cs
2009-11-29 12:27:46 UTC (rev 6374)
@@ -18,8 +18,7 @@
using System.Collections;
/// <summary>
- /// Represents the sliced data and offers
- /// a few read only properties to create a pagination bar.
+ /// Represents the sliced data and offers a few read-only properties to
create a pagination bar.
/// </summary>
[Serializable]
public class Page : AbstractPage
@@ -90,8 +89,7 @@
}
/// <summary>
- /// Creates an enumerator for the
- /// sliced set
+ /// Creates an enumerator for the sliced set.
/// </summary>
/// <returns>An enumerator instance</returns>
File [modified]: Page.cs
Delta lines: +10 -10
===================================================================
---
Components/Pagination/trunk/src/Castle.Components.Pagination/PaginationSupport.cs
2009-11-29 12:09:51 UTC (rev 6373)
+++
Components/Pagination/trunk/src/Castle.Components.Pagination/PaginationSupport.cs
2009-11-29 12:27:46 UTC (rev 6374)
@@ -17,15 +17,15 @@
using System;
using System.Collections;
using System.Collections.Generic;
+ using System.Linq;
-
/// <summary>
/// Common pagination support methods
/// </summary>
public static class PaginationSupport
{
/// <summary>
- /// Subsititute for System.Linq.Enumerable.ElementAt
+ /// Subsititute for <see cref="Enumerable.ElementAt{TSource}"/>.
/// </summary>
/// <param name="enumerable"></param>
/// <param name="itemIndex"></param>
@@ -35,9 +35,9 @@
EnsureItemIndexIsInRange(itemIndex);
object item;
-
+
IList list = enumerable as IList;
-
+
if (list != null)
{
item = list[itemIndex];
@@ -52,7 +52,7 @@
{
enumerator.MoveNext();
currentIndex++;
- }
+ }
while (currentIndex < itemIndex);
item = enumerator.Current;
@@ -70,7 +70,7 @@
}
/// <summary>
- /// Subsititute for System.Linq.Enumerable.ElementAt
+ /// Subsititute for Subsititute for <see
cref="Enumerable.ElementAt{TSource}"/>.
/// </summary>
/// <param name="enumerable"></param>
/// <param name="itemIndex"></param>
@@ -80,9 +80,9 @@
EnsureItemIndexIsInRange(itemIndex);
T item;
-
+
IList<T> list = enumerable as IList<T>;
-
+
if (list != null)
{
item = list[itemIndex];
@@ -97,9 +97,9 @@
{
enumerator.MoveNext();
currentIndex++;
- }
+ }
while (currentIndex < itemIndex);
-
+
item = enumerator.Current;
}
File [modified]: PaginationSupport.cs
Delta lines: +53 -54
===================================================================
---
Components/Pagination/trunk/src/Castle.Components.Pagination.Tests/BasePaginatedPageTestCase.cs
2009-11-29 12:09:51 UTC (rev 6373)
+++
Components/Pagination/trunk/src/Castle.Components.Pagination.Tests/BasePaginatedPageTestCase.cs
2009-11-29 12:27:46 UTC (rev 6374)
@@ -14,8 +14,7 @@
namespace Castle.Components.Pagination.Tests
{
- using System;
- using System.Collections;
+ using System.Collections;
using System.Collections.Generic;
using NUnit.Framework;
@@ -25,10 +24,10 @@
public void TestExpectedResultForFirstPageWithSingleItemPage()
{
IList sampleData = GetSampleListData();
-
+
int currentPageIndex = 1;
int pageSize = 1;
-
+
IPaginatedPage page =
CreateAbstractPageWithSampleData(sampleData, currentPageIndex, pageSize);
AssertIsOnFirstPageHavingMultiplePages(page);
@@ -50,12 +49,12 @@
public void TestExpectedResultForMiddlePageWithSingleItemPage()
{
IList sampleData = GetSampleListData();
-
+
int currentPageIndex = 3;
int pageSize = 1;
IPaginatedPage page =
CreateAbstractPageWithSampleData(sampleData, currentPageIndex, pageSize);
-
+
Assert.AreEqual(currentPageIndex,
page.CurrentPageIndex);
Assert.AreEqual(sampleData.Count, page.TotalPages);
Assert.IsTrue(page.HasPreviousPage);
@@ -69,7 +68,7 @@
Assert.AreEqual(page.FirstItem, page.LastItem);
Assert.AreEqual("three", page.FirstItem);
Assert.AreEqual(1, page.CurrentPageSize);
-
+
AssertHasPageIsTrueBetween(page, 1, sampleData.Count,
-1, sampleData.Count + 2);
AssertGetEnumeratorItterateOverExpectedValues(page,
"three");
}
@@ -78,12 +77,12 @@
public void TestExpectedResultForLastPageWithSingleItemPage()
{
IList sampleData = GetSampleListData();
-
+
int currentPageIndex = sampleData.Count;
int pageSize = 1;
-
+
IPaginatedPage page =
CreateAbstractPageWithSampleData(GetSampleListData(), currentPageIndex,
pageSize);
-
+
AssertIsOnLastPageHavingMultiplePages(page);
Assert.AreEqual(currentPageIndex,
page.CurrentPageIndex);
Assert.AreEqual(currentPageIndex + 1,
page.NextPageIndex);
@@ -103,12 +102,12 @@
public void TestExpectedResultForFirstPageWithTwoItemPerPage()
{
IList sampleData = GetSampleListData();
-
+
int currentPageIndex = 1;
int pageSize = 2;
-
+
IPaginatedPage page =
CreateAbstractPageWithSampleData(sampleData, currentPageIndex, pageSize);
-
+
AssertIsOnFirstPageHavingMultiplePages(page);
Assert.AreEqual(currentPageIndex + 1,
page.NextPageIndex);
Assert.AreEqual(currentPageIndex - 1,
page.PreviousPageIndex);
@@ -123,10 +122,10 @@
public void TestExpectedResultForMiddlePageWithTwoItemPerPage()
{
IList sampleData = GetSampleListData();
-
+
int currentPageIndex = 2;
int pageSize = 2;
-
+
IPaginatedPage page =
CreateAbstractPageWithSampleData(sampleData, currentPageIndex, pageSize);
Assert.AreEqual(4, page.LastItemIndex);
@@ -135,20 +134,20 @@
Assert.AreEqual(2, page.CurrentPageSize);
AssertGetEnumeratorItterateOverExpectedValues(page,
"three", "four");
- Assert.IsNotNull(page.FirstItem);
- Assert.IsNotNull(page.LastItem);
- Assert.AreEqual("three", page.FirstItem);
- Assert.AreEqual("four", page.LastItem);
- }
+ Assert.IsNotNull(page.FirstItem);
+ Assert.IsNotNull(page.LastItem);
+ Assert.AreEqual("three", page.FirstItem);
+ Assert.AreEqual("four", page.LastItem);
+ }
[Test]
public void TestExpectedResultForLastPageWithTwoItemPerPage()
{
IList sampleData = GetSampleListData();
-
+
int currentPageIndex = 3;
int pageSize = 2;
-
+
IPaginatedPage page =
CreateAbstractPageWithSampleData(sampleData, currentPageIndex, pageSize);
AssertIsOnLastPageHavingMultiplePages(page);
@@ -162,19 +161,19 @@
Assert.IsNotNull(page.LastItem);
}
- protected static void
AssertGetEnumeratorItterateOverExpectedValues(IPaginatedPage page, params
string[] values)
+ protected static void
AssertGetEnumeratorItterateOverExpectedValues(IPaginatedPage page, params
string[] values)
{
- int CurrentPageIndex = 0;
+ int currentPageIndex = 0;
foreach (string value in page)
{
- Assert.AreEqual(values[CurrentPageIndex],
value);
- ++CurrentPageIndex;
+ Assert.AreEqual(values[currentPageIndex],
value);
+ ++currentPageIndex;
}
}
private static void AssertHasPageIsTrueBetween(IPaginatedPage
page, int firstPageIndex, int lastPageIndex,
- int rangeLowerBound,
int rangeUpperBound)
+ int rangeLowerBound, int rangeUpperBound)
{
for (int i = rangeLowerBound, max = rangeUpperBound; i
< max; ++i)
{
@@ -203,7 +202,7 @@
Assert.AreEqual(page.TotalPages, page.CurrentPageIndex);
}
- protected static IList GetSampleListData()
+ protected static IList GetSampleListData()
{
return new ArrayList(new string[] {"one", "two",
"three", "four", "five"});
}
@@ -237,19 +236,19 @@
[TestFixture]
public class GenericCustomPageTestCase : BasePaginatedPageTestCase
{
- protected override IPaginatedPage
CreateAbstractPageWithSampleData(IList sampleData, int currentPage, int
pageSize)
- {
- return CreateGenericCustomPageWithSampleData(sampleData,
currentPage, pageSize);
- }
-
- private IPaginatedPage<string>
CreateGenericCustomPageWithSampleData(IList sampleData, int currentPage, int
pageSize)
+ protected override IPaginatedPage
CreateAbstractPageWithSampleData(IList sampleData, int currentPage, int
pageSize)
{
+ return
CreateGenericCustomPageWithSampleData(sampleData, currentPage, pageSize);
+ }
+
+ private IPaginatedPage<string>
CreateGenericCustomPageWithSampleData(IList sampleData, int currentPage, int
pageSize)
+ {
IList<string> genericData = new List<string>(pageSize);
-
+
int firstindex = (currentPage - 1) * pageSize;
-
+
int lastindex = firstindex + pageSize - 1;
-
+
for (int i = 0; i < sampleData.Count; ++i)
{
if (i < firstindex)
@@ -268,26 +267,26 @@
return new GenericCustomPage<string>(genericData,
currentPage, pageSize, sampleData.Count);
}
- [Test]
- public void
TestExpectedResultForMiddlePageWithTwoItemPerPageForGenericPage()
- {
- IList sampleData = GetSampleListData();
+ [Test]
+ public void
TestExpectedResultForMiddlePageWithTwoItemPerPageForGenericPage()
+ {
+ IList sampleData = GetSampleListData();
- int currentPageIndex = 2;
- int pageSize = 2;
+ int currentPageIndex = 2;
+ int pageSize = 2;
- IPaginatedPage<string> page =
CreateGenericCustomPageWithSampleData(sampleData, currentPageIndex, pageSize);
+ IPaginatedPage<string> page =
CreateGenericCustomPageWithSampleData(sampleData, currentPageIndex, pageSize);
- Assert.AreEqual(4, page.LastItemIndex);
- Assert.AreEqual(currentPageIndex + 1, page.NextPageIndex);
- Assert.AreEqual(currentPageIndex - 1, page.PreviousPageIndex);
- Assert.AreEqual(2, page.CurrentPageSize);
- AssertGetEnumeratorItterateOverExpectedValues(page, "three",
"four");
+ Assert.AreEqual(4, page.LastItemIndex);
+ Assert.AreEqual(currentPageIndex + 1,
page.NextPageIndex);
+ Assert.AreEqual(currentPageIndex - 1,
page.PreviousPageIndex);
+ Assert.AreEqual(2, page.CurrentPageSize);
+ AssertGetEnumeratorItterateOverExpectedValues(page,
"three", "four");
- Assert.IsNotNull(page.FirstItem);
- Assert.IsNotNull(page.LastItem);
- Assert.AreEqual("three", page.FirstItem);
- Assert.AreEqual("four", page.LastItem);
- }
+ Assert.IsNotNull(page.FirstItem);
+ Assert.IsNotNull(page.LastItem);
+ Assert.AreEqual("three", page.FirstItem);
+ Assert.AreEqual("four", page.LastItem);
+ }
}
}
Directory: /Components/Pagination/trunk/src/Castle.Components.Pagination.Tests/
===============================================================================
File [modified]: BasePaginatedPageTestCase.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.