using Autofac;
using ESuite.UI.E2E.Hooks;
using ESuite.UI.E2E.StepDefinitions;
using Reqnroll.Autofac;
using System.Linq;
using System.Reflection;

namespace ESuite.UI.E2E
{
    public static class DependencyConfig
    {
        [ScenarioDependencies]
        public static void ConfigureDependencies(ContainerBuilder builder)
        {
            var stepDefinitionTypes = Assembly.GetExecutingAssembly()
                                               .GetTypes()
                                               .Where(t => t.Name.EndsWith("StepDefinitions"));

            // Register all StepDefinition classes as themselves
            foreach (var type in stepDefinitionTypes)
            {
                builder.RegisterType(type).AsSelf().InstancePerLifetimeScope();
            }

            // Register specific hooks or other necessary dependencies
            builder.RegisterType<ScenarioHooks>().As<ScenarioHooks>().InstancePerLifetimeScope();

        }
    }
}