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

namespace eSuite.API.UnitTests.Controllers.SiteControllerUnitTests;

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

    [Test]
    public async Task GetSite_WhenCalled_ReturnsPagedData()
    {
        //Arrange
        var site = new ReadSite();

        var cancellationToken = CancellationToken.None;

        var generalIdRef = new GeneralIdRef();

        _siteManagerMock.Setup(x => x.GetSite(generalIdRef, cancellationToken)).ReturnsAsync(site);

        //Act
        var actualResult = await _siteController.GetSite(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(site));
    }
}