using e_suite.API.Common.models;
using eSuite.Core.Miscellaneous;
using Microsoft.AspNetCore.Mvc;
using Moq;
using NUnit.Framework;

namespace eSuite.API.UnitTests.Controllers.RoleControllerUnitTests;

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

    [Test]
    public async Task GetDomains_WhenCalled_ReturnsPagedData()
    {
        //Arrange
        var role = new ReadRole
        {
            Guid = new Guid("35aad917-131a-4b67-9a0c-c1b1ff519bec"),
            Id = 564,
            Name = "Some Role"
        };

        var cancellationToken = CancellationToken.None;
        var generalIdRef = new GeneralIdRef();

        _roleManagerMock.Setup(x => x.GetRole(It.IsAny<GeneralIdRef>(), cancellationToken)).ReturnsAsync(role);

        //Act
        var actualResult = await _roleController.GetRole(generalIdRef.Id, generalIdRef.Guid, 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.EqualTo(role));
    }
}