Lumiera  0.pre.03
»edit your freedom«
DependencyConfiguration_test Class Reference

Description

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
Remarks
this test basically covers the same ground as DependencyFactory_test; but while the latter exists since our second rewrite of lib::Depend (2013), this test here is a byproduct of the third rewrite from 2018 and focuses more on the configuration and instance identities.
See also
lib::Dependency
Singleton_test

Definition at line 97 of file dependency-configuration-test.cpp.

Private Member Functions

virtual void run (Arg)
 
void verify_automaticReplacement ()
 
void verify_customFactory ()
 
void verify_expose_Service_with_Lifecycle ()
 
void verify_Singleton ()
 
void verify_SubclassSingleton ()
 

Member Function Documentation

◆ verify_Singleton()

void verify_Singleton ( )
inlineprivate
Test:
without special configuration, singletons are injected as dependency

Definition at line 119 of file dependency-configuration-test.cpp.

◆ verify_SubclassSingleton()

void verify_SubclassSingleton ( )
inlineprivate
Test:
preconfigure a specific subclass to be injected as singleton dependency

Definition at line 146 of file dependency-configuration-test.cpp.

References VERIFY_ERROR.

◆ verify_expose_Service_with_Lifecycle()

void verify_expose_Service_with_Lifecycle ( )
inlineprivate
Test:
expose a dedicated service instance, which can be shut down

Definition at line 169 of file dependency-configuration-test.cpp.

◆ verify_automaticReplacement()

void verify_automaticReplacement ( )
inlineprivate
Test:
injecting test mocks temporarily

Definition at line 207 of file dependency-configuration-test.cpp.

◆ 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 316 of file dependency-configuration-test.cpp.

+ Inheritance diagram for DependencyConfiguration_test:
+ Collaboration diagram for DependencyConfiguration_test:

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