Class TeaPieTestingExtensions
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
teaPieTeaPieThe current context instance.
directiveNamestringThe name of the directive, excluding the 'TEST-' prefix.
directivePatternstringThe regular expression pattern for matching the directive. Use TestDirectivePatternBuilder for easier pattern composition.
testNameGetterFunc<IReadOnlyDictionary<string, string>, string>A function that generates the full test name. A dictionary of parameters is provided for customization of the test name.
testFunctionFunc<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
teaPieTeaPieThe current context instance.
testNamestringThe name of the test.
testFunctionActionThe testing function to execute.
skipTestboolIndicates 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
teaPieTeaPieThe current context instance.
testNamestringThe name of the test.
testFunctionFunc<Task>The asynchronous testing function to execute.
skipTestboolIndicates whether the test should be skipped (true) or normally executed (false). Defaults to false.