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

namespace eSuite.API.UnitTests.Controllers.FormsControllerUnitTests;

[TestFixture]
public class GetFormInstanceUnitTests : FormsControllerTestBase
{
    [SetUp]
    public override async Task Setup()
        => await base.Setup();

    [Test]
    public async Task GetFormInstance_NormanConditions_Returns200OkObjResult()
    {
        //Arrange
        var generalIdRef = new GeneralIdRef
        {
            Guid = new Guid("320951a7-ba70-419f-8263-411aec720d59"),
            Id = 5,
        };

        var formInstance = new ReadFormInstance();

        var cancellationToken = CancellationToken.None;

        _formsManagerMock!.Setup(x => x.GetFormInstanceAsync(generalIdRef, cancellationToken)).ReturnsAsync(formInstance);

        //Act
        var res = await _formsController.GetFormInstance(generalIdRef, cancellationToken);

        //Assert
        Assert.That(res.GetType(), Is.EqualTo(typeof(OkObjectResult)));

        var objectResult = (OkObjectResult)res;
        Assert.That(objectResult.Value, Is.EqualTo(formInstance));
    }
}