- Test:
- verify the various modes of creating dependencies.
- standard case is singleton creation
- configuration of a specific subclass for the singleton
- expose a service with explicit lifecycle
- use of a custom factory function
- injection of a mock implementation for unit tests
- See also
- lib::Dependency
-
Singleton_test
Definition at line 88 of file dependency-configuration-test.cpp.
◆ verify_Singleton()
void verify_Singleton |
( |
| ) |
|
|
inlineprivate |
◆ verify_SubclassSingleton()
void verify_SubclassSingleton |
( |
| ) |
|
|
inlineprivate |
◆ verify_expose_Service_with_Lifecycle()
void verify_expose_Service_with_Lifecycle |
( |
| ) |
|
|
inlineprivate |
◆ verify_automaticReplacement()
void verify_automaticReplacement |
( |
| ) |
|
|
inlineprivate |
◆ verify_customFactory()
void verify_customFactory |
( |
| ) |
|
|
inlineprivate |
- Test:
- instance creation can be preconfigured with a closure.
Both Singleton and Test-Mock creation can optionally be performed through a user provided Lambda or Functor. To demonstrate this, we use a Veryspecial
local class, which takes an int&
as constructor parameter – and we create the actual instance through a lambda, which happens to capture a local variable by reference.
- Warning
- this can be dangerous; in the example demonstrated here, the created singleton instance continues to live until termination of the test-suite. After leaving this test function, it thus holds a dangling reference, pointing into stack memory....
Definition at line 307 of file dependency-configuration-test.cpp.
The documentation for this class was generated from the following file: