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

namespace eSuite.API.UnitTests.Controllers.DomainControllerUnitTests;

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

    [Test]
    public async Task GetDomain_WhenCalled_ReturnsOKResultWithData()
    {
        //Arrange
        var generalIdRef = new GeneralIdRef
        {
            Guid = new Guid("f6bfa906-a4f6-41a0-bbad-06b77af8ac50")
        };

        var cancellationToken = CancellationToken.None;

        var domain = new GetDomain();
        _domainManagerMock.Setup(x => x.GetDomainAsync(generalIdRef, cancellationToken)).ReturnsAsync(domain);

        //Act
        var actualResult = await _domainController.GetDomain(generalIdRef, cancellationToken);

        //Assert
        _domainManagerMock.Verify(x => x.GetDomainAsync(generalIdRef, cancellationToken), Times.Once);

        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(domain));
    }
}