SmartTester
2.0.0
Smart Tester is unit testing and regression testing framework used for testing SmartCGMS system.
|
#include <SignalGeneratorUnitTester.h>
Public Member Functions | |
void | executeSpecificTests () override |
Executes all tests for a specific filter. Needs to be implemented by derived class. More... | |
void | loadEntity () override |
We need to override the loading behavior, because executing events upon signal generator that is not configured always fails with E_FAIL, therefore all generic tests would fail. Every test, requiring custom configuration, has to reconfigure the filter. More... | |
HRESULT | asynchronousModeTest () |
HRESULT | shutdownAfterLastTest () |
HRESULT | timeSegmentStartTest () |
HRESULT | twiceIdenticalTimeSegmentStartTest () |
HRESULT | eventDeviceTimeLessThanSteppingTest () |
HRESULT | eventDeviceTimeAsSteppingTest () |
HRESULT | eventDeviceTimeAsSeveralSteppingsTest () |
HRESULT | echoDefaultParametersAsEventTest () |
![]() | |
FilterUnitTester (GUID guid, const EntityType &type) | |
HRESULT | infoEventTest () |
HRESULT | warningEventTest () |
HRESULT | errorEventTest () |
HRESULT | warmResetEventTest () |
HRESULT | shutDownEventTest () |
void | executeConfigTest (const std::wstring &testName, const tester::FilterConfig &configuration, HRESULT expectedResult) |
void | executeAllTests () override |
Every derived class has to override this method to execute all tests. More... | |
void | executeGenericTests () |
![]() | |
EntityUnitTester (const GUID &entityGuid) | |
bool | isEntityLoaded () const noexcept |
CDynamic_Library & | getEntityLib () noexcept |
const GUID & | getEntityGuid () const noexcept |
void | loadEntityLibrary () |
const wchar_t * | getEntityName (const std::string &symbolName) |
![]() | |
void | executeTest (const std::wstring &testName, const std::function< HRESULT(void)> &test) |
Additional Inherited Members | |
![]() | |
HRESULT | configurationTest (const tester::FilterConfig &config, HRESULT expectedResult) |
HRESULT | shutDownTest () override |
Creates shut down event and executes it with tested filter. | |
HRESULT | configureFilter (const tester::FilterConfig &configuration) |
TestFilter & | getTestFilter () |
![]() | |
void | setEntityLib (const std::wstring &libPath) |
void | setLibraryPath (const std::wstring &libraryPath) noexcept |
const std::wstring & | getLibraryPath () const |
scgms::IFilter * | getTestedEntity () noexcept |
void | setTestedEntity (scgms::IFilter *entity) |
void | runTest (const std::function< HRESULT()> &test) override |
We need special behavior of the test execution sequence, so we override this method. More... | |
![]() | |
std::mutex | m_testMutex |
std::condition_variable | m_testCv |
HRESULT | m_lastTestResult = S_OK |
Derived class used for testing of the Signal Generator filter.
HRESULT tester::SignalGeneratorUnitTester::asynchronousModeTest | ( | ) |
If the model is not synchronized, it should be stepped only as far as the configured maximum time. This test checks, whether this behavior is present or not. That means, that maximum of (maximum_time/stepping)*(N+1) events should be emitted. (+1 for the initial state).
HRESULT tester::SignalGeneratorUnitTester::echoDefaultParametersAsEventTest | ( | ) |
When the synchronous signal generator is configured with the flag Echo_Default_Parameters_As_Event, the first event that is emitted by the signal generator should be a Parameters event with values of the parameters passed in a vector through the configuration. This test checks whether this event is emitted as the first one or not.
Stepping 5 minutes
Setting segmentStartEvent's segment id to a valid value
Starting at this time
HRESULT tester::SignalGeneratorUnitTester::eventDeviceTimeAsSeveralSteppingsTest | ( | ) |
Synchronous signal generator works in a way that it calls Step method of the model with configured stepping value only when there is an event executed upon the signal generator that has device_time higher than the event that caused the last calling of the Step method by the stepping value.
When the executed event has the device_time increased by several steppings, the Step method of the model should be called as many times with linearly increased stepping by stepping value as it fits into the event's device_time value and each time the current state in that time should be emitted. This test checks whether these states are emitted or not.
Stepping 5 minutes
Setting segmentStartEvent's segment id to a valid value
Starting at this time
Generator emits current state when registers time segment start
Clearing events so we can easily check incoming event count after next execution
setting level event's segment id to the same value as the previous event
With stepping 5 minutes, adding twenty minutes should emit states
in several other times
states in 4 times should be emitted
HRESULT tester::SignalGeneratorUnitTester::eventDeviceTimeAsSteppingTest | ( | ) |
Synchronous signal generator works in a way that it calls Step method of the model with configured stepping value only when there is an event executed upon the signal generator that has device_time higher than the event that caused the last calling of the Step method by the stepping value.
When the executed event has the device_time increased by a little bit more than the stepping value, the Step method of the model should be called and next state in time increased by stepping should be emitted. This test checks if this next state is emitted or not.
Stepping 5 minutes
Setting segmentStartEvent's segment id to a valid value
Starting at this time
Generator emits current state when registers time segment start
setting level event's segment id to the same value as the previous event
With stepping 5 minutes, adding seven minutes should call the step method
HRESULT tester::SignalGeneratorUnitTester::eventDeviceTimeLessThanSteppingTest | ( | ) |
Synchronous signal generator works in a way that it calls Step method of the model with configured stepping value only when there is an event executed upon the signal generator that has device_time higher than the event that caused the last calling of the Step method by the stepping value.
When the executed event has the device_time increased by less than the stepping value, no event should be emitted by the signal generator. This test checks, whether this event is emitted or not.
Stepping 5 minutes
Setting segmentStartEvent's segment id to a valid value
Starting at this time
Generator emits current state when registers time segment start
setting level event's segment id to the same value as the previous event
With stepping 5 minutes, adding one minute should not return any event
We added less time than the stepping is, so the event should not be emitted, +1 for the executed event
|
overridevirtual |
Executes all tests for a specific filter. Needs to be implemented by derived class.
Configuration tests
When signal synchronization set to false, crashes on std::invalid_logic exception thrown in the filter
Functional tests
Implements tester::FilterUnitTester.
|
overridevirtual |
We need to override the loading behavior, because executing events upon signal generator that is not configured always fails with E_FAIL, therefore all generic tests would fail. Every test, requiring custom configuration, has to reconfigure the filter.
Resetting so there will not be data from last test present
Reimplemented from tester::FilterUnitTester.
HRESULT tester::SignalGeneratorUnitTester::shutdownAfterLastTest | ( | ) |
In asynchronous mode, when the signal generator is configured with shutdown_after_last flag, after the generation is over, filter should emit a Shut_Down event. This test checks, whether the Shut_Down event is emitted or not.
HRESULT tester::SignalGeneratorUnitTester::timeSegmentStartTest | ( | ) |
When executing Time_Segment_Start event upon synchronous signal generator, it should emit the current model state. This test checks, whether the current state is emitted or not.
Setting event's segment id to a valid value
Generator should emit current state when registers time segment start - no events is an error
HRESULT tester::SignalGeneratorUnitTester::twiceIdenticalTimeSegmentStartTest | ( | ) |
Executing Time_Segment_Start event starts generator's control loop for given segment. That means, that it should be allowed to execute this loop only once for each segment. This test checks, whether executing Time_Segment_Start event for the same segment twice will end with failure or not.
Time segment start for the same segment_id should return an error
Setting event's segment id to a valid value