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

#include <LogFilterUnitTester.h>

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

Public Member Functions

void executeSpecificTests () override
 Executes all tests for a specific filter. Needs to be implemented by derived class. More...
 
HRESULT logFileGenerationTest ()
 
HRESULT logRowCountTest ()
 
HRESULT filterOutputTest ()
 
HRESULT eventOrderTest ()
 
HRESULT popResultRepeatingTest ()
 
HRESULT popEventCountTest ()
 
- 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 from GenericUnitTester responsible for testing of Log filter.

Member Function Documentation

◆ eventOrderTest()

HRESULT tester::LogFilterUnitTester::eventOrderTest ( )

When there are events executed upon LogFilter in specific order, there should be records of these events in the log file in the same order. This test executes level, info and parameters event upon LogFilter and checks if the records of these events in the log file are in correct order.

Returns
S_OK if the log file contains records of executed events in correct order, otherwise E_FAIL

If something went wrong, releasing all existing events

If something went wrong, releasing all existing events

+1 for the header

Checking second line - first line is header, third field is event code

◆ executeSpecificTests()

void tester::LogFilterUnitTester::executeSpecificTests ( )
overridevirtual

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

Configuration tests

the test above should create junk file so we delete it

Functional tests

Implements tester::FilterUnitTester.

◆ filterOutputTest()

HRESULT tester::LogFilterUnitTester::filterOutputTest ( )

When there is an event executed upon the LogFilter, there should be a line describing the executed event. This test executes one level event upon the LogFilter and then checks if the event was logged into the log file.

Returns
S_OK if the log file contains record of level event, otherwise E_FAIL

Checking second line - first line is header, third field is event code

◆ logFileGenerationTest()

HRESULT tester::LogFilterUnitTester::logFileGenerationTest ( )

If LogFilter is successfully configured with Log_File attribute value present, text file with identical name should be created. This method tests if it is true. Returns S_OK only if the log file is created, otherwise returns E_FAIL.

Returns
S_OK if log file is created, otherwise E_FAIL

File should exist already after successful configuration

◆ logRowCountTest()

HRESULT tester::LogFilterUnitTester::logRowCountTest ( )

When there is N events executed upon the LogFilter, there should be a line for every single event that was executed, plus one for the header. This test will execute 3 level events and a shutdown event upon the LogFilter and checks, whether there are 5 lines present in the generated log file.

Returns
S_OK if log file contains 5 lines, otherwise E_FAIL

If creating failed, setting flag to failed

If something went wrong, releasing all existing events

If something went wrong, releasing all existing events

Forcing logs to be displayed in the log

Here not returning E_FAIL, will try to check the log anyways

+2 for header and shut down event

◆ popEventCountTest()

HRESULT tester::LogFilterUnitTester::popEventCountTest ( )

Executing Pop method should always return a line for every event, that was executed upon the filter. This test executes three level events upon the LogFilter and checks, whether the Pop method returns tree log records.

Returns
S_OK if three log records are returned from the Pop method, otherwise E_FAIL

◆ popResultRepeatingTest()

HRESULT tester::LogFilterUnitTester::popResultRepeatingTest ( )

Executing Pop method should always return the difference between this and the last calling. This test executes level event and checks the Pop interface twice. At first Pop should return the executed event and the second time the event should not be returned anymore.

Returns
S_OK if the executed event is not returned twice, otherwise E_FAIL

Popping the same event for the second time should return false


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