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.SsoManagerControllerUnitTests;

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

    [Test]
    public async Task GetSsoProvidersAsync_NormalConditions_ReturnsOkObjResult()
    {
        //Arrange
        var paginatedData = new PaginatedData<ReadSsoProvider>
        {
            Count = 2,
            Data = new List<ReadSsoProvider> { new() },
            Page = 1,
            PageSize = 10
        };

        SsoManagerMock?.Setup(x => x.GetSsoProvidersAsync(It.IsAny<Paging>(), It.IsAny<CancellationToken>()))
            .ReturnsAsync(paginatedData);

        var paging = new Paging();

        //Act
        var res = await SsoManagerController.GetProviders(paging);

        //Assert
        Assert.That(res, Is.Not.Null);
        Assert.That(res?.GetType(), Is.EqualTo(typeof(OkObjectResult)));
    }
}