using e_suite.Database.Core.Tables.Domain;
using e_suite.Modules.RoleManager.UnitTests.Helpers;
using e_suite.Utilities.Pagination;
using NUnit.Framework;

namespace e_suite.Modules.RoleManager.UnitTests;

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

    [Test]
    public async Task GetRoleAccess_WhenCalled_ReturnsRollAccess()
    {
        //Arrange
        var paging = new Paging
        {
            Page = 0
        };

        var role = new Role
        {
            Id = 199,
            Guid = new Guid("89458573-0495-48a8-ae21-dc4f72e52d5e"),
            Name = "My Role",
            IsAdministrator = false,
            IsSuperUser = false
        };

        RoleManagerRepository.RoleAccess.Add( new RoleAccess
        {
            Role = role,
            RoleId = role.Id,
            AccessKey = 1,
        });

        //Act
        var actualResult = await RoleManager.GetRoleAccess(paging, CancellationToken.None);

        //Assert
        Assert.That(actualResult, Is.Not.Null);
        Assert.That(actualResult.Count, Is.EqualTo(RoleManagerRepository.RoleAccess.Count));
        Assert.That(actualResult.Data.Count(), Is.EqualTo(RoleManagerRepository.RoleAccess.Count));
    }
}