using Autofac;
using Insight.Database;
using PlanTempus.Components;
using PlanTempus.Components.Accounts.Create;
using PlanTempus.Core.CommandQueries;
using PlanTempus.Core.Database;
using PlanTempus.Core.Database.ConnectionFactory;
using Shouldly;
namespace PlanTempus.X.TDD.CommandQueryHandlerTests;

[TestClass]
public class HandlerTest : TestFixture
{
    [TestInitialize]
    public void This()
    {
    }

    [TestMethod]
    public async Task ShouldResolveCommandHandlerAndDispatchToGenericCommandHandler()
    {
        var commandHandler = Container.Resolve<ICommandHandler>();
        commandHandler.ShouldBeOfType<CommandHandler>();

        var command = new CreateAccountCommand
        {
            Email = $"{GetRandomWord()}@dumbanddumber.com5", // Lloyd Christmas
            Password = "1234AceVentura#LOL", // Ace Ventura
            IsActive = true,
            CorrelationId = Guid.NewGuid()
        };

        var result = await commandHandler.Handle(command);

        result.ShouldNotBeNull();
    }
}