Environment helper to set up a service provider. More...
#include <ProviderTestHelpers.h>
Environment helper to set up a service provider.
Prov | type of provider being set up |
TestEnv | type of environment to set up |
The setup()
static method of this class implements a simple set up of a service provider Prov in an existing testing environment:
static Prov* setup(TestEnv&);
If such a class is available for a given provider, the environment testing::TesterEnvironment offers the one-stop SimpleProviderSetup()
method for the complete set up of that provider.
The setup() function will typically:
The environment is expected to expose an interface equivalent to the one of testing::TesterEnvironment
.
See SimpleEnvironmentStandardSetupClass for a class suitable as base class for your own implementation.
To implement a setup for MyProvider, the specialisation can follow the pattern:
template <typename TestEnv> struct SimpleEnvironmentSetupClass<MyProvider, TestEnv> { static MyProvider* setup(TestEnv& env) { // create and set up the provider, e.g. auto prov = std::make_unique<MyProvider>( // constructor arguments... ); // yield and register the provider to the environment MyProvider* prov_ptr = env.AcquireProvider<MyProvider>(prov); return prov_ptr; } // setup() }; // SimpleEnvironmentSetupClass<MyProvider>
Note that the class must be fully constructed by the default constructor, in order for it to work with the tester environment.
Definition at line 155 of file ProviderTestHelpers.h.