using e_suite.API.Common.models;
using e_suite.Utilities.Pagination;
using Microsoft.AspNetCore.Mvc;
using Moq;
using NUnit.Framework;

namespace eSuite.API.UnitTests.Controllers.SiteControllerUnitTests;

[TestFixture]
public class GetSitesUnitTests : SiteControllerTestBase
{
    [SetUp]
    public override async Task Setup()
    {
        await base.Setup();
    }

    [Test]
    public async Task GetSites_WhenCalled_ReturnsPagedData()
    {
        //Arrange
        var domains = new List<ReadSite>();

        var paginatedData = new PaginatedData<ReadSite>
        {
            Count = domains.Count,
            Data = domains,
            Page = 1,
            PageSize = 10
        };

        var cancellationToken = CancellationToken.None;

        var paging = new Paging();

        _siteManagerMock.Setup(x => x.GetSites(paging, cancellationToken)).ReturnsAsync(paginatedData);

        //Act
        var actualResult = await _siteController.GetSites(paging, cancellationToken);

        //Assert
        Assert.That(actualResult.GetType(), Is.EqualTo(typeof(OkObjectResult)));
        var objectResult = actualResult as OkObjectResult;

        Assert.That(objectResult?.StatusCode, Is.EqualTo(200));
        Assert.That(objectResult?.Value, Is.Not.Null);
        Assert.That(objectResult!.Value!.GetType, Is.EqualTo(typeof(PaginatedData<ReadSite>)));
    }
}