Skip to main content

Definition

Assembly: CloudNimble.Breakdance.Assemblies.dll Namespace: CloudNimble.Breakdance.Assemblies.Http Inheritance: System.Net.Http.DelegatingHandler

Syntax

CloudNimble.Breakdance.Assemblies.Http.ResponseSnapshotHandlerBase

Summary

Base class for Response Snapshot handlers that enable testing with real captured HTTP responses.

Remarks

Response Snapshots are real HTTP responses captured from actual API calls and stored as files. This allows testing against real response data without hitting live endpoints or polluting third-party services with test data. Use ResponseSnapshotCaptureHandler to capture responses from live APIs, then use ResponseSnapshotReplayHandler to replay those responses in tests.

Constructors

.ctor

Creates a new ResponseSnapshotHandlerBase with the specified snapshot storage path.

Syntax

public ResponseSnapshotHandlerBase(string responseSnapshotsPath)

Parameters

NameTypeDescription
responseSnapshotsPathstringRoot folder path for storing response snapshot files.

Examples

var handler = new ResponseSnapshotReplayHandler("TestData/Snapshots");
var client = new HttpClient(handler);

Properties

ResponseSnapshotsPath

Gets the root folder path where response snapshot files are stored.

Syntax

public string ResponseSnapshotsPath { get; private set; }

Property Value

Type: string

Methods

GetFileExtensionString

Maps the MediaType header in the HttpRequestMessage to a known list of file extensions.

Syntax

public static string GetFileExtensionString(System.Net.Http.HttpRequestMessage request)

Parameters

NameTypeDescription
requestSystem.Net.Http.HttpRequestMessageThe request to examine.

Returns

Type: string The file extension string for the request’s Accept header.

Exceptions

ExceptionDescription
ArgumentNullExceptionThrown when request is null.

GetResponseMediaTypeString

Maps the file extension in the specified path to a known list of media types.

Syntax

public static string GetResponseMediaTypeString(string filePath)

Parameters

NameTypeDescription
filePathstringThe file path to examine.

Returns

Type: string The MIME type string for the file extension.