Skip to main content

Definition

Assembly: CloudNimble.Breakdance.DotHttp.dll Namespace: CloudNimble.Breakdance.DotHttp Inheritance: CloudNimble.Breakdance.Assemblies.BreakdanceTestBase

Syntax

CloudNimble.Breakdance.DotHttp.DotHttpTestBase

Summary

Base class for generated .http file tests. Provides HTTP client management, variable resolution, and response capture for request chaining.

Remarks

Inherits from BreakdanceTestBase for integration with the Breakdance testing framework. Generated test classes are partial, allowing customization of setup and assertions.

Examples

public partial class ApiTests : DotHttpTestBase
{
    protected override HttpMessageHandler CreateHttpMessageHandler()
    {
        // Use cached responses for deterministic tests
        return new TestCacheReadDelegatingHandler("ResponseFiles");
    }

    partial void OnLoginSetup()
    {
        SetVariable("baseUrl", "https://api.example.com");
    }
}

Methods

LoadEnvironment

Loads environment configuration from an http-client.env.json file.

Syntax

public void LoadEnvironment(string filePath, string environmentName = null)

Parameters

NameTypeDescription
filePathstringThe path to the environment file.
environmentNamestringThe environment to use (e.g., “dev”, “staging”).

Examples

LoadEnvironment("http-client.env.json", "dev");
// Now variables from the dev environment are available

LoadEnvironmentWithOverrides

Loads environment configuration with user overrides.

Syntax

public void LoadEnvironmentWithOverrides(string baseFilePath, string userFilePath, string environmentName = null)

Parameters

NameTypeDescription
baseFilePathstringThe path to the http-client.env.json file.
userFilePathstringThe path to the http-client.env.json.user file.
environmentNamestringThe environment to use.

Examples

LoadEnvironmentWithOverrides(
    "http-client.env.json",
    "http-client.env.json.user",
    "dev");

SetVariable

Sets a variable for use in request resolution.

Syntax

public void SetVariable(string name, string value)

Parameters

NameTypeDescription
namestringThe variable name (without @ prefix or wrapper).
valuestringThe variable value.

Examples

SetVariable("baseUrl", "https://api.example.com");
SetVariable("apiKey", "my-secret-key");

SwitchEnvironment

Switches to a different environment from the loaded configuration.

Syntax

public void SwitchEnvironment(string environmentName)

Parameters

NameTypeDescription
environmentNamestringThe environment name to switch to.

Examples

LoadEnvironment("http-client.env.json", "dev");
// Run dev tests...
SwitchEnvironment("staging");
// Now running with staging variables

TestSetupAsync Override

Sets up the test environment.

Syntax

public override System.Threading.Tasks.Task TestSetupAsync()

Returns

Type: System.Threading.Tasks.Task

TestTearDownAsync Override

Cleans up resources after each test.

Syntax

public override System.Threading.Tasks.Task TestTearDownAsync()

Returns

Type: System.Threading.Tasks.Task