using e_suite.API.Common;
using e_suite.API.Common.models;
using e_suite.Service.EFlowSync.EflowAPI;
using e_suite.Service.EFlowSync.UnitTests.FakeRepositories;
using e_suite.UnitTestCore;
using e_suite.Utilities.Pagination;
using Moq;

namespace e_suite.Service.EFlowSync.UnitTests.Helpers;

public class SyncEFlowTestBase : TestBase
{
    protected Mock<IDomainManager> DomainManagerMock { get; set; } = null!;
    protected Mock<IEFlowCategories> EFlowCategoriesMock { get; set; } = null!;
    protected FakeFormsRepository FakeFormRepository { get; set; }= null!;
    protected FakeSpecificationManagerRepository FakeSpecificationManagerRepository { get; set; }= null!;
    protected FakeEFlowSyncRepository FakeEFlowSyncRepository { get; set; } = null!;
    protected IEFlowSync EFlowSync { get; set; } = null!;


    public List<GetDomain> Domains = new List<GetDomain>();

    public PaginatedData<GetDomain> DomainsToLookup { get; set; } = null!;

    public override async Task Setup()
    {
        await base.Setup();

        Domains.Add(new GetDomain
        {
            Guid = new Guid("{63CAC905-ACEA-48D4-9FAA-25DEB34DE123}"),
            Id = 1,
            Name = "TestDomain",
            SunriseAppId = "Testing",
            SunriseCategoryId = "Category1"
        });
        Domains.Add(new GetDomain
        {
            Guid = new Guid("{AA176AD4-85B5-418D-80FA-B73BC7B419F0}"),
            Id = 2,
            Name = "MyDomain"
        });
        Domains.Add(new GetDomain
        {
            Guid = new Guid("{D3271945-FD84-4FCA-84AC-77CC07D4BF89}"),
            Id = 3,
            Name = "ADifferentDomain"
        });

        DomainsToLookup = new PaginatedData<GetDomain>
        {
            Data = Domains
        };

        DomainManagerMock = new Mock<IDomainManager>();
        DomainManagerMock.Setup(x => x.GetDomainsAsync(It.IsAny<Paging>(), It.IsAny<CancellationToken>())).Returns(
            () => Task.FromResult((IPaginatedData<GetDomain>)DomainsToLookup));

        EFlowCategoriesMock = new Mock<IEFlowCategories>();
        FakeFormRepository = new FakeFormsRepository();
        FakeSpecificationManagerRepository = new FakeSpecificationManagerRepository();
        FakeEFlowSyncRepository = new FakeEFlowSyncRepository();

        EFlowSync = new Service.EFlowSync.EFlowSync(DomainManagerMock.Object, EFlowCategoriesMock.Object, FakeFormRepository, FakeSpecificationManagerRepository, FakeEFlowSyncRepository);
    }
}