RTC Toolkit 5.1.0
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
rtctk::componentFramework::test::RepositoryIfTestSuiteLegacy< T > Class Template Reference

A test suite for performing acceptance tests of a RepositoryIf implementation. More...

#include <rtctk/componentFramework/test/repositoryIfTestSuiteLegacy.hpp>

Inheritance diagram for rtctk::componentFramework::test::RepositoryIfTestSuiteLegacy< T >:

Public Member Functions

void SetUp () override
 
void TearDown () override
 
template<class U >
std::shared_ptr< UCreateRepository ()
 Constructs a new instance of a repository adapter that derives from RepositoryIf.
 
template<class U >
void CleanupRepository (std::shared_ptr< U > &adapter)
 A cleanup function that is invoked before destroying a repository adapter of a given type.
 
std::shared_ptr< PersistentRepoAdapterCreateRepository ()
 
void CleanupRepository (std::shared_ptr< PersistentRepoAdapter > &adapter)
 

Protected Attributes

std::shared_ptr< T > m_adapter
 

Detailed Description

template<typename T>
class rtctk::componentFramework::test::RepositoryIfTestSuiteLegacy< T >

A test suite for performing acceptance tests of a RepositoryIf implementation.

Any adapter classes that derive from RepositoryIf can instantiate these parameterised tests to check compliance of the new adapter. To instantiate the test suite one should use the INSTANTIATE_TYPED_TEST_SUITE_P macro as described in the Google Test documentation. The setup and teardown methods will call templated functions for CreateRepository and CleanupRepository. These should be specialised and provided by the user of this test suite for each repository adapter type that will be tested. The purpose of these template functions is to create and then cleanup an instance of the repository adapter for a given type. If calling the default destructor is sufficient for correctly tearing down the adapter of a given type, then there is no need to provide a custom CleanupRepository, since this is done by default.

The following is sample code showing how to instantiate this test suite for an example adapter called MyAdapter in a unit test source file:

typedef testing::Types<MyAdapter> AdapterTypes;
template <> template <>
...
}
template <> template <>
std::shared_ptr<MyAdapter>& adapter) {
...
}
INSTANTIATE_TYPED_TEST_SUITE_P(TestMyAdapter,
RepositoryIfTestSuiteLegacy,
AdapterTypes,
testing::internal::DefaultNameGenerator);
} // namespace rtctk::componentFramework::test
A test suite for performing acceptance tests of a RepositoryIf implementation.
Definition repositoryIfTestSuiteLegacy.hpp:80
Definition fakeClock.cpp:15
elt::mal::future< std::string > InjectReqRepEvent(StateMachineEngine &engine)
Definition malEventInjector.hpp:23
Header file declaring type parameterised tests for RepositoryIf.

Note that only the CreateRepository, CleanupRepository and INSTANTIATE_TYPED_TEST_SUITE_P definitions should be contained within the rtctk::componentFramework::test namespace when instantiating the test suite. This is to avoid that Doxygen inappropriately adds any other definitions to the API documentation for the namespace.

Member Function Documentation

◆ CleanupRepository() [1/2]

◆ CleanupRepository() [2/2]

template<typename T >
template<class U >
void rtctk::componentFramework::test::RepositoryIfTestSuiteLegacy< T >::CleanupRepository ( std::shared_ptr< U > & adapter)
inline

A cleanup function that is invoked before destroying a repository adapter of a given type.

If additional cleanup is necessary for a specific repository type then a specialisation of this template function should be provided.

Template Parameters
UThe type of adapter being destroyed.
Parameters
[in,out]adapterThe adapter object that was originally created with CreateRepository.

◆ CreateRepository() [1/2]

template<typename T >
template<class U >
std::shared_ptr< U > rtctk::componentFramework::test::RepositoryIfTestSuiteLegacy< T >::CreateRepository ( )

Constructs a new instance of a repository adapter that derives from RepositoryIf.

Specialisations of this template function should be created for each repository type that needs to be created.

Template Parameters
UThe type of adapter to create.
Returns
A new instance of the adapter.

◆ CreateRepository() [2/2]

◆ SetUp()

template<typename T >
void rtctk::componentFramework::test::RepositoryIfTestSuiteLegacy< T >::SetUp ( )
inlineoverride

◆ TearDown()

template<typename T >
void rtctk::componentFramework::test::RepositoryIfTestSuiteLegacy< T >::TearDown ( )
inlineoverride

Member Data Documentation

◆ m_adapter

template<typename T >
std::shared_ptr<T> rtctk::componentFramework::test::RepositoryIfTestSuiteLegacy< T >::m_adapter
protected

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