mirror of
https://github.com/Sea-Haven-Industries/shoc-backend.git
synced 2026-09-30 08:23:12 +00:00
34 lines
1.1 KiB
C#
34 lines
1.1 KiB
C#
using FluentAssertions;
|
|
using SeaHaven.Services.DTOs;
|
|
using Xunit;
|
|
|
|
namespace SeaHaven.Services.Tests;
|
|
|
|
public class PagedResultTests
|
|
{
|
|
[Theory]
|
|
[InlineData(0, 10, 0)]
|
|
[InlineData(10, 10, 1)]
|
|
[InlineData(25, 10, 3)]
|
|
[InlineData(100, 25, 4)]
|
|
public void TotalPages_IsCeilingOfCountOverPageSize(int totalCount, int pageSize, int expectedPages)
|
|
{
|
|
var result = new PagedResult<string> { TotalCount = totalCount, PageSize = pageSize, Page = 1 };
|
|
|
|
result.TotalPages.Should().Be(expectedPages);
|
|
}
|
|
|
|
[Fact]
|
|
public void HasPrevious_IsFalseOnFirstPage_TrueAfterward()
|
|
{
|
|
new PagedResult<string> { Page = 1, PageSize = 10, TotalCount = 30 }.HasPrevious.Should().BeFalse();
|
|
new PagedResult<string> { Page = 2, PageSize = 10, TotalCount = 30 }.HasPrevious.Should().BeTrue();
|
|
}
|
|
|
|
[Fact]
|
|
public void HasNext_IsTrueBeforeLastPage_FalseOnLastPage()
|
|
{
|
|
new PagedResult<string> { Page = 2, PageSize = 10, TotalCount = 30 }.HasNext.Should().BeTrue();
|
|
new PagedResult<string> { Page = 3, PageSize = 10, TotalCount = 30 }.HasNext.Should().BeFalse();
|
|
}
|
|
}
|