using System.Reflection;
using System.Text.Json;

namespace e_suite.UnitTestCore;

public class AutomationTestBase
{
    protected TestEnvironment TestEnvironment { get; }

    public AutomationTestBase()
    {
        var executingAssembly = Assembly.GetCallingAssembly();
        var assemblyConfigurationAttribute = executingAssembly.GetCustomAttribute<AssemblyConfigurationAttribute>();
        var buildConfigurationName = assemblyConfigurationAttribute?.Configuration;

        var fileName = $"config.{buildConfigurationName}.json";
        string jsonString = File.ReadAllText(fileName);
        TestEnvironment = JsonSerializer.Deserialize<TestEnvironment>(jsonString)!;
    }
}