Skip to content

Commit

Permalink
(#113) add Paged attribute to RowLimit
Browse files Browse the repository at this point in the history
  • Loading branch information
nils-a committed Oct 27, 2023
1 parent 724c44f commit 329b20b
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
20 changes: 19 additions & 1 deletion src/CamlGen.Tests/Elements/Value/RowLimitTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,28 @@ public class RowLimitTests : TestBase
public void RowLimitWitANumberPrintsTheRowLimit()
{
var limit = Fixture.Create<int>();
var sut = new RowLimit(limit);
var sut = new RowLimit(limit, null);

sut.ToString().ShouldBe(string.Format("<RowLimit>{0}</RowLimit>", limit));
}

[Fact]
public void RowLimitPagedWitANumberPrintsTheRowLimit()
{
var limit = Fixture.Create<int>();
var sut = new RowLimit(limit, true);

sut.ToString().ShouldBe(string.Format("<RowLimit Paged=\"TRUE\">{0}</RowLimit>", limit));
}

[Fact]
public void RowLimitNotPagedWitANumberPrintsTheRowLimit()
{
var limit = Fixture.Create<int>();
var sut = new RowLimit(limit, false);

sut.ToString().ShouldBe(string.Format("<RowLimit Paged=\"FALSE\">{0}</RowLimit>", limit));
}

[Fact]
public void AViewCanSetARowLimit()
Expand Down
6 changes: 3 additions & 3 deletions src/CamlGen/Elements/Core/View.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,10 @@ public View QueryOptions(Action<QueryOptions> action)
/// Add a RowLimit to this View
/// </summary>
/// <param name="rowLimit"></param>
/// <returns></returns>
public View RowLimit(int rowLimit)
/// <returns>Fluent <see cref="View"/></returns>
public View RowLimit(int rowLimit, bool? paged = null)
{
var child = new RowLimit(rowLimit);
var child = new RowLimit(rowLimit, paged);
Childs.Add(child);
return this;
}
Expand Down
8 changes: 7 additions & 1 deletion src/CamlGen/Elements/Value/RowLimit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,21 @@ All other rights reserved.
WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
***/

using System;
using System.Globalization;

namespace FluentCamlGen.CamlGen.Elements.Value
{
internal class RowLimit : BaseValueElement
{
internal RowLimit(int rowLimit)
internal RowLimit(int rowLimit, bool? paged)
: base("RowLimit", rowLimit.ToString(CultureInfo.InvariantCulture))
{
if (paged.HasValue)
{
var val = paged.Value ? "TRUE" : "FALSE";
Attributes.Add(new Tuple<string, string>("Paged", val));
}
}
}
}

0 comments on commit 329b20b

Please sign in to comment.