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

namespace e_suite.Modules.OrganisationManager.UnitTests;

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

    [Test]
    public async Task ShouldReturnOrganisationsList()
    {
        // Arrange
        var organisation1 = new Organisation
        {
            Id = 1,
            Guid = Guid.NewGuid(),
            Name = "Sun Strategy",
            Address = "London, United Kingdom",
            Status = OrganisationStatus.Active
        };

        var organisation2 = new Organisation
        {
            Id = 2,
            Guid = Guid.NewGuid(),
            Name = "Microsoft",
            Address = "Mountain View, USA",
            Status = OrganisationStatus.Active
        };

        var organisation3 = new Organisation
        {
            Id = 3,
            Guid = Guid.NewGuid(),
            Name = "Twitter",
            Address = "Mountain View, USA",
            Status = OrganisationStatus.Active,
            Deleted = true
        };

        FakeOrganisationManagerRepository.Organisations.Add(organisation1);
        FakeOrganisationManagerRepository.Organisations.Add(organisation2);
        FakeOrganisationManagerRepository.Organisations.Add(organisation3);

        var paging = new Paging()
        {
            Page = 1,
            PageSize = 10,
            SortAscending = true,
            Filters = string.Empty
        };

        // Act
        var result = await OrganisationManager.GetOrganisationList(paging, default);

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