> ## Documentation Index
> Fetch the complete documentation index at: https://easyaf.nimbleapps.cloud/llms.txt
> Use this file to discover all available pages before exploring further.

# DotHttpTestBase

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

## Definition

**Assembly:** CloudNimble.Breakdance.DotHttp.dll

**Namespace:** CloudNimble.Breakdance.DotHttp

**Inheritance:** CloudNimble.Breakdance.Assemblies.BreakdanceTestBase

## Syntax

```csharp theme={"dark"}
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

```csharp theme={"dark"}
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

### &#x20;LoadEnvironment

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

#### Syntax

```csharp theme={"dark"}
public void LoadEnvironment(string filePath, string environmentName = null)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `filePath` | `string` | The path to the environment file. |
| `environmentName` | `string` | The environment to use (e.g., "dev", "staging"). |

#### Examples

```csharp theme={"dark"}
LoadEnvironment("http-client.env.json", "dev");
// Now variables from the dev environment are available
```

### &#x20;LoadEnvironmentWithOverrides

Loads environment configuration with user overrides.

#### Syntax

```csharp theme={"dark"}
public void LoadEnvironmentWithOverrides(string baseFilePath, string userFilePath, string environmentName = null)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `baseFilePath` | `string` | The path to the http-client.env.json file. |
| `userFilePath` | `string` | The path to the http-client.env.json.user file. |
| `environmentName` | `string` | The environment to use. |

#### Examples

```csharp theme={"dark"}
LoadEnvironmentWithOverrides(
    "http-client.env.json",
    "http-client.env.json.user",
    "dev");
```

### &#x20;SetVariable

Sets a variable for use in request resolution.

#### Syntax

```csharp theme={"dark"}
public void SetVariable(string name, string value)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `name` | `string` | The variable name (without @ prefix or  wrapper). |
| `value` | `string` | The variable value. |

#### Examples

```csharp theme={"dark"}
SetVariable("baseUrl", "https://api.example.com");
SetVariable("apiKey", "my-secret-key");
```

### &#x20;SwitchEnvironment

Switches to a different environment from the loaded configuration.

#### Syntax

```csharp theme={"dark"}
public void SwitchEnvironment(string environmentName)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `environmentName` | `string` | The environment name to switch to. |

#### Examples

```csharp theme={"dark"}
LoadEnvironment("http-client.env.json", "dev");
// Run dev tests...
SwitchEnvironment("staging");
// Now running with staging variables
```

### &#x20;TestSetupAsync Override

Sets up the test environment.

#### Syntax

```csharp theme={"dark"}
public override System.Threading.Tasks.Task TestSetupAsync()
```

#### Returns

Type: `System.Threading.Tasks.Task`

### &#x20;TestTearDownAsync Override

Cleans up resources after each test.

#### Syntax

```csharp theme={"dark"}
public override System.Threading.Tasks.Task TestTearDownAsync()
```

#### Returns

Type: `System.Threading.Tasks.Task`


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.