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

namespace eSuite.API.UnitTests.Controllers.SpecificationControllerUnitTests;

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

    [Test]
    public async Task GetSpecification_WhenCalled_ReturnsPagedData()
    {
        //Arrange
        var specification = new ReadSpecification();


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

        _specificationManagerMock.Setup(x => x.GetSpecification(generalIdRef, cancellationToken)).ReturnsAsync(specification);

        //Act
        var actualResult = await _specificationController.GetSpecification(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.Not.Null);
        Assert.That(objectResult!.Value!.GetType, Is.EqualTo(typeof(ReadSpecification)));
    }
}