using Reqnroll; namespace API.Specs.Steps; /// /// Shared / plumbing and the /// keys used to coordinate it, common to every step definition class that drives the test API. /// public abstract class ApiStepsBase(ScenarioContext scenario) { protected ScenarioContext Scenario { get; } = scenario; protected const string ClientKey = "client"; protected const string FactoryKey = "factory"; protected const string ResponseKey = "response"; protected const string ResponseBodyKey = "responseBody"; protected TestApiFactory GetFactory() { TestApiFactory? factory = Scenario.TryGetValue( FactoryKey, out TestApiFactory? f ) ? f : new TestApiFactory(); Scenario[FactoryKey] = factory; return factory; } protected HttpClient GetClient() { if (Scenario.TryGetValue(ClientKey, out HttpClient? client)) return client; client = GetFactory().CreateClient(); Scenario[ClientKey] = client; return client; } }