Table of Contents

Class FailureScenarioServiceExtensions

Namespace
ReferenceApplication.Web.Extensions
Assembly
ReferenceApplication.Web.dll

Registers and maps the explicitly enabled, Development-only failure scenarios and their fault-injection seams.

public static class FailureScenarioServiceExtensions
Inheritance
FailureScenarioServiceExtensions
Inherited Members

Fields

RoutePrefix

Gets the route prefix of the failure-scenario API.

public const string RoutePrefix = "/api/v1/failure-scenarios"

Field Value

string

Methods

AddApplicationFailureScenarios(IServiceCollection, IConfiguration, IHostEnvironment)

Registers the scenarios and their seams only when their switch is enabled in Development and the disposable demonstration database is in use.

public static IServiceCollection AddApplicationFailureScenarios(this IServiceCollection services, IConfiguration configuration, IHostEnvironment environment)

Parameters

services IServiceCollection

The service collection to configure.

configuration IConfiguration

The application configuration.

environment IHostEnvironment

The host environment.

Returns

IServiceCollection

The same service collection so calls can be chained.

Remarks

Call after AddApplicationDataAccess, AddApplicationAsiBackbone, AddApplicationGovernanceEvidence, and AddApplicationCapabilityTokens. Outside an active Development host nothing is registered: no demonstration constraint, no save interceptor, no middleware, and no route.

The seams act only on a request that consumed an armed run, or, for delivery, on the audit completion of that request, so they leave every other request unchanged.

IsActive(IConfiguration, IHostEnvironment)

Determines whether the scenarios are enabled in Development with the demonstration database in use.

public static bool IsActive(IConfiguration configuration, IHostEnvironment environment)

Parameters

configuration IConfiguration

The application configuration.

environment IHostEnvironment

The host environment.

Returns

bool

true when the scenarios are active.

MapApplicationFailureScenarios(WebApplication)

Maps the administrator-only failure-scenario routes only when the scenarios are active.

public static WebApplication MapApplicationFailureScenarios(this WebApplication app)

Parameters

app WebApplication

The application.

Returns

WebApplication

The same application so calls can be chained.

UseApplicationFailureScenarios(WebApplication)

Adds the middleware that consumes armed runs, only when the scenarios are active. Call between authorization and endpoint governance, so the run's actor is known and governance sees the run.

public static WebApplication UseApplicationFailureScenarios(this WebApplication app)

Parameters

app WebApplication

The application.

Returns

WebApplication

The same application so calls can be chained.