Table of Contents

Class TeaPieTestingExtensions

Namespace
TeaPie.Testing
Assembly
TeaPie.dll
public static class TeaPieTestingExtensions
Inheritance
TeaPieTestingExtensions
Inherited Members

Methods

RegisterTestDirective(TeaPie, string, string, Func<IReadOnlyDictionary<string, string>, string>, Func<HttpResponseMessage, IReadOnlyDictionary<string, string>, Task>)

Registers a custom test directive that can be used within a '.http' file for any request.

public static void RegisterTestDirective(this TeaPie teaPie, string directiveName, string directivePattern, Func<IReadOnlyDictionary<string, string>, string> testNameGetter, Func<HttpResponseMessage, IReadOnlyDictionary<string, string>, Task> testFunction)

Parameters

teaPie TeaPie

The current context instance.

directiveName string

The name of the directive, excluding the 'TEST-' prefix.

directivePattern string

The regular expression pattern for matching the directive. Use TestDirectivePatternBuilder for easier pattern composition.

testNameGetter Func<IReadOnlyDictionary<string, string>, string>

A function that generates the full test name. A dictionary of parameters is provided for customization of the test name.

testFunction Func<HttpResponseMessage, IReadOnlyDictionary<string, string>, Task>

The test function to execute when the directive is applied. The function receives the HTTP response as an HttpResponseMessage and a dictionary of parameters.

Test(TeaPie, string, Action, bool)

Executes the specified testFunction as a test method. If testFunction throws an exception, the test is considered failed. If no exception is thrown, the test is considered passed. The test will be referenced by testName in the results.

public static void Test(this TeaPie teaPie, string testName, Action testFunction, bool skipTest = false)

Parameters

teaPie TeaPie

The current context instance.

testName string

The name of the test.

testFunction Action

The testing function to execute.

skipTest bool

Indicates whether the test should be skipped (true) or normally executed (false). Defaults to false.

Test(TeaPie, string, Func<Task>, bool)

Executes the specified asynchronous testFunction as a test method. If testFunction throws an exception, the test is considered failed. If no exception is thrown, the test is considered passed. The test will be referenced by testName in the results.

public static Task Test(this TeaPie teaPie, string testName, Func<Task> testFunction, bool skipTest = false)

Parameters

teaPie TeaPie

The current context instance.

testName string

The name of the test.

testFunction Func<Task>

The asynchronous testing function to execute.

skipTest bool

Indicates whether the test should be skipped (true) or normally executed (false). Defaults to false.

Returns

Task