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

namespace eSuite.API.UnitTests.Controllers.UserManagerControllerUnitTests;

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

    [Test]
    public async Task GetUsers_WhenCalled_ReturnsPagedData()
    {
        //Arrange
        var user = new GetUser();

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

        _userManagerMock.Setup(x => x.GetUserAsync(generalIdRef, cancellationToken)).ReturnsAsync(user);

        //Act
        var actualResult = await _userManagerController.GetUser(generalIdRef, 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(user));
    }
}