mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-10-14 17:54:42 +00:00
Enforce brewery ownership on update and delete (#267)
This commit is contained in:
39
web/backend/API/API.Specs/Steps/ApiStepsBase.cs
Normal file
39
web/backend/API/API.Specs/Steps/ApiStepsBase.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using Reqnroll;
|
||||
|
||||
namespace API.Specs.Steps;
|
||||
|
||||
/// <summary>
|
||||
/// Shared <see cref="TestApiFactory" />/<see cref="HttpClient" /> plumbing and the <see cref="ScenarioContext" />
|
||||
/// keys used to coordinate it, common to every step definition class that drives the test API.
|
||||
/// </summary>
|
||||
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<TestApiFactory>(
|
||||
FactoryKey,
|
||||
out TestApiFactory? f
|
||||
)
|
||||
? f
|
||||
: new TestApiFactory();
|
||||
Scenario[FactoryKey] = factory;
|
||||
return factory;
|
||||
}
|
||||
|
||||
protected HttpClient GetClient()
|
||||
{
|
||||
if (Scenario.TryGetValue<HttpClient>(ClientKey, out HttpClient? client))
|
||||
return client;
|
||||
|
||||
client = GetFactory().CreateClient();
|
||||
Scenario[ClientKey] = client;
|
||||
return client;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user