Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
ComponentTestHelper Class Reference

Class to test a single component. More...

#include <ComponentTest.h>

Collaboration diagram for ComponentTestHelper:

Public Member Functions

 ComponentTestHelper (ScriptContext &scriptContext)
 
const ScriptInterfaceGetScriptInterface ()
 
CSimContextGetSimContext ()
 
template<typename T >
TAdd (EComponentTypeId cid, const std::string &xml, entity_id_t ent=10)
 Call this once to initialise the test helper with a component. More...
 
void AddMock (entity_id_t ent, EInterfaceId iid, IComponent &component)
 
void HandleMessage (IComponent *cmp, const CMessage &msg, bool global)
 
void Roundtrip (bool verbose=false)
 Checks that the object roundtrips through its serialize/deserialize functions correctly. More...
 

Private Attributes

CSimContext m_Context
 
CComponentManager m_ComponentManager
 
CParamNode m_Param
 
IComponentm_Cmp
 
EComponentTypeId m_Cid
 
bool m_isSystemEntityInit = false
 

Detailed Description

Class to test a single component.

  • Create an instance of this class
  • Use AddMock to add mock components that the tested component relies on
  • Use Add to add the test component itself, and it returns a component pointer
  • Call methods on the component pointer
  • Use Roundtrip to test the consistency of serialization

Constructor & Destructor Documentation

◆ ComponentTestHelper()

ComponentTestHelper::ComponentTestHelper ( ScriptContext scriptContext)
inline

Member Function Documentation

◆ Add()

template<typename T >
T * ComponentTestHelper::Add ( EComponentTypeId  cid,
const std::string &  xml,
entity_id_t  ent = 10 
)
inline

Call this once to initialise the test helper with a component.

◆ AddMock()

void ComponentTestHelper::AddMock ( entity_id_t  ent,
EInterfaceId  iid,
IComponent component 
)
inline

◆ GetScriptInterface()

const ScriptInterface & ComponentTestHelper::GetScriptInterface ( )
inline

◆ GetSimContext()

CSimContext & ComponentTestHelper::GetSimContext ( )
inline

◆ HandleMessage()

void ComponentTestHelper::HandleMessage ( IComponent cmp,
const CMessage msg,
bool  global 
)
inline

◆ Roundtrip()

void ComponentTestHelper::Roundtrip ( bool  verbose = false)
inline

Checks that the object roundtrips through its serialize/deserialize functions correctly.

Computes the debug output, hash, and binary serialization; then deserializes into a new system and checks the serialization outputs are unchanged.

Member Data Documentation

◆ m_Cid

EComponentTypeId ComponentTestHelper::m_Cid
private

◆ m_Cmp

IComponent* ComponentTestHelper::m_Cmp
private

◆ m_ComponentManager

CComponentManager ComponentTestHelper::m_ComponentManager
private

◆ m_Context

CSimContext ComponentTestHelper::m_Context
private

◆ m_isSystemEntityInit

bool ComponentTestHelper::m_isSystemEntityInit = false
private

◆ m_Param

CParamNode ComponentTestHelper::m_Param
private

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