using System.Reflection;
namespace ZB.MOM.WW.ScadaBridge.ManagementService.Tests;
public class ManagementPagingBoundaryTests
{
/// Verifies that a positive take is capped, while an omitted or non-positive take preserves unlimited paging.
/// The requested page size, or null when omitted.
/// The number of rows expected back.
[Theory]
[InlineData(null, 1100)]
[InlineData(-1, 1100)]
[InlineData(0, 1100)]
[InlineData(1, 1)]
[InlineData(1000, 1000)]
[InlineData(1001, 1000)]
[InlineData(int.MaxValue, 1000)]
public void PositiveTakeIsCapped_OmittedOrNonpositiveTakePreservesUnlimited(int? take, int expected)
{
var page = typeof(ManagementActor).GetMethod("Page", BindingFlags.Static | BindingFlags.NonPublic)!.MakeGenericMethod(typeof(int));
var rows = (List)page.Invoke(null, [Enumerable.Range(0, 1100), -1, take])!;
Assert.Equal(expected, rows.Count);
Assert.Equal(0, rows[0]);
}
}