SmartTester  2.0.0
Smart Tester is unit testing and regression testing framework used for testing SmartCGMS system.
Public Member Functions | List of all members
tester::SignalGeneratorUnitTester Class Reference

#include <SignalGeneratorUnitTester.h>

Inheritance diagram for tester::SignalGeneratorUnitTester:
Inheritance graph
[legend]
Collaboration diagram for tester::SignalGeneratorUnitTester:
Collaboration graph
[legend]

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 ()
 
- Public Member Functions inherited from tester::FilterUnitTester
 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 ()
 
- Public Member Functions inherited from tester::EntityUnitTester< scgms::IFilter >
 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)
 
- Public Member Functions inherited from tester::TestRunner
void executeTest (const std::wstring &testName, const std::function< HRESULT(void)> &test)
 

Additional Inherited Members

- Protected Member Functions inherited from tester::FilterUnitTester
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)
 
TestFiltergetTestFilter ()
 
- Protected Member Functions inherited from tester::EntityUnitTester< scgms::IFilter >
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...
 
- Protected Attributes inherited from tester::TestRunner
std::mutex m_testMutex
 
std::condition_variable m_testCv
 
HRESULT m_lastTestResult = S_OK
 

Detailed Description

Derived class used for testing of the Signal Generator filter.

Member Function Documentation

◆ asynchronousModeTest()

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).

Returns
S_OK if the model was stepped only to the maximum time, otherwise E_FAIL

◆ echoDefaultParametersAsEventTest()

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.

Returns
S_OK if the Parameters event is emitted as the first event, otherwise E_FAIL

Stepping 5 minutes

Setting segmentStartEvent's segment id to a valid value

Starting at this time

◆ eventDeviceTimeAsSeveralSteppingsTest()

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.

Returns
S_OK if all states in future times are emitted, otherwise E_FAIL

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

◆ eventDeviceTimeAsSteppingTest()

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.

Returns
S_OK if next state in time increased by stepping is emitted, otherwise E_FAIL

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

◆ eventDeviceTimeLessThanSteppingTest()

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.

Returns
S_OK if event with device_time increased by less than the stepping value to the last event, that caused the execution of Step method, is not emitted, otherwise E_FAIL

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

◆ executeSpecificTests()

void tester::SignalGeneratorUnitTester::executeSpecificTests ( )
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.

◆ loadEntity()

void tester::SignalGeneratorUnitTester::loadEntity ( )
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.

◆ shutdownAfterLastTest()

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.

Returns
S_OK if the Shut_Down event was emitted, otherwise E_FAIL

◆ timeSegmentStartTest()

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.

Returns
S_OK if the current state of the model was emitted, otherwise E_FAIL

Setting event's segment id to a valid value

Generator should emit current state when registers time segment start - no events is an error

◆ twiceIdenticalTimeSegmentStartTest()

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.

Returns
S_OK if the execution of second Time_Segment_Start with the same segment_id failed, otherwise E_FAIL

Time segment start for the same segment_id should return an error

Setting event's segment id to a valid value


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