using e_suite.Database.Core.Models;
using e_suite.Database.Core.Tables.Printer;
using e_suite.Modules.SiteManager.UnitTests.Helpers;
using e_suite.Utilities.Pagination;
using NUnit.Framework;

namespace e_suite.Modules.SiteManager.UnitTests;

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

    [Test]
    public async Task GetSites_WhenCalled_ReturnsExpectedResult()
    {
        //Arrange
        var paging = new Paging();

        var organisation = new Organisation
        {
            Guid = new Guid("0bed12bd-3cce-4dda-aa1f-8796a1edcc80"),
            Id = 12345,
            Name = "Test Organisation"
        };

        var site = new Site
        {
            Guid = new Guid("b85c48bb-1dc3-4d60-aae6-888f8c90073d"),
            Id = 21354,
            Name = "Test Site",
            Status = OrganisationStatus.Active,
            Address = "123 Somewhere street",
            Organisation = organisation,
            OrganisationId = organisation.Id
        };
        SiteManagerRepository.Sites.Add(site);
        
        //Act
        var result = await SiteManager.GetSites(paging, CancellationToken.None);

        //Assert
        Assert.That(result, Is.Not.Null);
        Assert.That(result.Count, Is.EqualTo(1));
        Assert.That(result.Data.Count(), Is.EqualTo(1));

        var firstSite = result.Data.First();
        Assert.That(firstSite.Guid, Is.EqualTo(site.Guid));
        Assert.That(firstSite.Id, Is.EqualTo(site.Id));
        Assert.That(firstSite.Name, Is.EqualTo(site.Name));
    }
}