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::ModelUnitTester Class Reference

#include <ModelUnitTester.h>

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

Public Member Functions

 ModelUnitTester (const GUID &guid, const std::wstring &libPath)
 
void executeSpecificTests () override
 Executes all tests for a specific filter. Needs to be implemented by derived class. More...
 
HRESULT modelFlagTest ()
 
HRESULT modelCreationTest (const scgms::NModel_Flags &modelFlag)
 
HRESULT invalidParameterCountTest ()
 
HRESULT initializePositiveCurrentTimeTest ()
 
HRESULT repeatedInitializeCallTest ()
 
HRESULT stepBeforeInitializeTest ()
 
HRESULT negativeStepDeltaTimeTest ()
 
HRESULT currentTimeStepTest ()
 
HRESULT futureTimeStepTest ()
 
- 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 with tests for individual models.

Member Function Documentation

◆ currentTimeStepTest()

HRESULT tester::ModelUnitTester::currentTimeStepTest ( )

When Step method is called with time_advance_delta = 0.0, current state should always be emitted. This test checks, whether events emitted by calling Step(0.0), even after stepping by N, represent current time state of the model.

Returns
S_OK if correct events were emitted, otherwise E_FAIL

Checking state in time 0

Epsilon for comparing double values

Moving by 0.6

Checking state in time += 0.6

Clearing events so we can tell when nothing was sent to us

Checking current state in the stepped time

◆ executeSpecificTests()

void tester::ModelUnitTester::executeSpecificTests ( )
overridevirtual

Executes all tests for a specific filter. Needs to be implemented by derived class.

Continuing with tests for discrete models

Executing generic tests after we executed and passed all the construction tests

Implements tester::FilterUnitTester.

◆ futureTimeStepTest()

HRESULT tester::ModelUnitTester::futureTimeStepTest ( )

When Step method is called with positive time_advance_delta, future state of N units from now should be emitted. This test checks, whether any events are emitted and if so, whether they represent the right time or not.

Returns
S_OK if correct events were emitted, otherwise E_FAIL

Checking state in time 1

Epsilon for comparing double values

◆ initializePositiveCurrentTimeTest()

HRESULT tester::ModelUnitTester::initializePositiveCurrentTimeTest ( )

Calling initialize method of a model while passing positive current_time value should not result in an error. This test checks, whether the initialization with positive time passes or not.

Returns
S_OK if initialization passes, otherwise E_FAIL

◆ invalidParameterCountTest()

HRESULT tester::ModelUnitTester::invalidParameterCountTest ( )

When the vector of parameters, passed to the model constructor, is shorter that it's descriptor says it should be, filter should not be created. This test checks, if the size of given vector is validated.

Returns
S_OK if model was not created with invalid parameter count, otherwise E_FAIL

Making sure we get invalid number of parameters

◆ modelCreationTest()

HRESULT tester::ModelUnitTester::modelCreationTest ( const scgms::NModel_Flags &  modelFlag)

If model has Discrete_Model flag, it should be possible to construct its object, otherwise it should not be possible. This test checks, whether the model can be created and returns result based on given flags of the model.

Parameters
modelFlagflags of created model
Returns
S_OK if creation result checks with given model flags, otherwise E_FAIL

◆ modelFlagTest()

HRESULT tester::ModelUnitTester::modelFlagTest ( )

Every model should have Discrete_Model of Signal_Model flag in the descriptor. This test checks if one of these flags is in model's descriptor.

Returns
S_OK if Discrete_Model is found, S_FALSE if Signal_Model is found and E_FAIL if error occurred or no valid flag found

◆ negativeStepDeltaTimeTest()

HRESULT tester::ModelUnitTester::negativeStepDeltaTimeTest ( )

Step method has to he called with non-negative time_advance_delta, because it says the state in which time should be emitted. This test checks whether calling Step method with negative time_advance_delta returns an error or not.

Returns
S_OK if calling Step with negative time_advance_delta returned an error, otherwise E_FAIL

◆ repeatedInitializeCallTest()

HRESULT tester::ModelUnitTester::repeatedInitializeCallTest ( )

Initialization of a model should be allowed to happen only once. When called repeatedly, every other initialization should fail with E_ILLEGAL_STATE_CHANGE error. This test checks whether all following initializations fail with expected error or not.

Returns
S_OK if all following initializations fail with E_ILLEGAL:STATE_CHANGE, otherwise E_FAIL

◆ stepBeforeInitializeTest()

HRESULT tester::ModelUnitTester::stepBeforeInitializeTest ( )

Step method must not be called before Initialize was called. This test checks, whether calling Step before Initialize returns an error or not.

Returns
S_OK if Step returns an error, otherwise E_FAIL

Trying to emit current state


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