All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
testing::SimpleEnvironmentSetupClass< Prov, TestEnv > Struct Template Reference

Environment helper to set up a service provider. More...

#include <ProviderTestHelpers.h>

Detailed Description

template<typename Prov, typename TestEnv>
struct testing::SimpleEnvironmentSetupClass< Prov, TestEnv >

Environment helper to set up a service provider.


Template Parameters
Provtype of provider being set up
TestEnvtype of environment to set up
See Also
simpleEnvironmentSetup()

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.


The documentation for this struct was generated from the following file: