From 4eec1d31e43cb10b4fdc0b72b79f89c6543cc5e9 Mon Sep 17 00:00:00 2001 From: Graham Watts Date: Wed, 12 Jan 2022 19:49:52 +0200 Subject: [PATCH] Add pre/post test hooks --- .../AdapterTestsBase.cs | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/src/DataCore.Adapter.Tests.Helpers/AdapterTestsBase.cs b/src/DataCore.Adapter.Tests.Helpers/AdapterTestsBase.cs index de3947db..50ae7303 100644 --- a/src/DataCore.Adapter.Tests.Helpers/AdapterTestsBase.cs +++ b/src/DataCore.Adapter.Tests.Helpers/AdapterTestsBase.cs @@ -74,6 +74,47 @@ protected virtual IAdapterCallContext CreateCallContext(TestContext context) { } + /// + /// Called immediately prior to the callback in , after the + /// has been started. + /// + /// + /// The adapter for the test. + /// + /// + /// The call context for the test. + /// + /// + /// The cancellation token for the test. + /// + /// + /// A that will perform any pre-test actions. + /// + protected virtual Task BeforeAdapterTestAsync(TAdapter adapter, IAdapterCallContext context, CancellationToken cancellationToken) { + return Task.CompletedTask; + } + + + /// + /// Called immediately after the callback in . + /// + /// + /// The adapter for the test. + /// + /// + /// The call context for the test. + /// + /// + /// The cancellation token for the test. + /// + /// + /// A that will perform any post-test actions. + /// + protected virtual Task AfterAdapterTestAsync(TAdapter adapter, IAdapterCallContext context, CancellationToken cancellationToken) { + return Task.CompletedTask; + } + + /// /// Creates and initialises a instance and runs an adapter /// test. @@ -104,7 +145,9 @@ protected async Task RunAdapterTest(Func