- unittestsreportersetup.zip
- UTestReporterSetup.exe
- unittestsreportersources.zip
- UnitTestsReporter
- Binaries
- Channel
- Include
- Sources
- Common.cpp
- Common
- Composite
- CppUnitLite
- Include
- Sources
- EasyTest.reg
- EasyTest.sln
- EasyTest
- EasyTestViewer
- Logger
- Mocks
- Objects
- Sample
- XMLTemplates
- sample_2k3.zip
- UTestReporter.2k3
- Channel
- Include
- Sources
- Common.cpp
- CppUnitLite
- Include
- Sources
- Sample
- XMLTemplates
- sample_vc6.zip
- UTestReporter.VC6
- Channel
- Include
- Sources
- Common.cpp
- CppUnitLite
- Include
- Sources
- Sample
- XMLTemplates
|
#ifndef _INTERFACE_CPP
#define _INTERFACE_CPP
#define WITHOUT_WINDOWS_DEFINITIONS
#include "TransportInterface.h"
#include "Logger.h"
#include "TestObject.h"
#include "Composite.h"
#include "MockComposite.h"
#include "MockEnvironment.h"
#include "MockEnvironmentObjectCreator.h"
#include "MockEnvironmentObjectCreatorExt.h"
Logger __logger;
typedef struct _session_
{
IEnvironmentObjectCreator<TestObject>* pEnvironmentObjectCreator;
MockEnvironment<TestObject>* pEnvironment;
}
TestSession;
TEST_SESSION StartSession()
{
TestSession* result = null;
result = new TestSession;
if (!result
) return result
;
result->pEnvironmentObjectCreator =
new MockEnvironmentObjectCreatorExt<TestObject>(&__logger);
if (!result->pEnvironmentObjectCreator)
{
FinalSession(reinterpret_cast<void**>(&result));
result = null;
return result;
}
result->pEnvironment =
new MockEnvironment<TestObject>(result->pEnvironmentObjectCreator,&__logger);
if (!result->pEnvironment)
{
FinalSession(reinterpret_cast<void**>(&result));
result = null;
return result;
}
// Clear tree...
return result;
}
bool FinalSession(TEST_SESSION* session)
{
bool result = false;
if (!session
) return result
;
if (!*session
) return result
;
TestSession
*pSession = static_cast<TestSession*>(*session);
if (pSession->pEnvironment)
delete pSession->pEnvironment;
if (pSession->pEnvironmentObjectCreator)
delete pSession->pEnvironmentObjectCreator;
delete pSession;
result = true;
return result;
}
TEST_OBJECT InsertObject(
TEST_SESSION session,
TEST_OBJECT parent,
char* name,
char* image,
ObjectType type)
{
TEST_OBJECT result = null;
IComponent<TestObject>* pComponent = null
;
if (!session
) return result
;
TestSession *pSession = static_cast<TestSession*>(session);
if (!pSession->pEnvironment
) return result
;
MockEnvironment<TestObject>*
mockEnvironment = static_cast<MockEnvironment<TestObject>*>(pSession->pEnvironment);
TestObject testObject(std::string(name),std::string(image),std::string(""),std::string(""));
if (type == Macro)
{
pComponent = new Leaf<TestObject>(testObject,pSession->pEnvironment);
if (!pComponent
) return result
;
pComponent->Object().SetOwner(pComponent);
IEnvironmentObject<TestObject>*
pEnvironmentObjectComposite = pSession->pEnvironmentObjectCreator->Create(pComponent->Object());
if (!pEnvironmentObjectComposite)
{
delete pComponent;
return result;
}
}
else
{
pComponent = new Composite<TestObject>(testObject,pSession->pEnvironment);
if (!pComponent
) return result
;
pComponent->Object().SetOwner(pComponent);
IEnvironmentObject<TestObject>*
pEnvironmentObjectComposite = pSession->pEnvironmentObjectCreator->Create(pComponent->Object());
if (!pEnvironmentObjectComposite)
{
delete pComponent;
return result;
}
if (type == Application)
{
MockEnvironmentObjectExt<TestObject>*
pObject = static_cast<MockEnvironmentObjectExt<TestObject>*>(pComponent->LinkedObject());
IComponent<int>* entityObject = pObject->Entity();
mockEnvironment->TreeControl()->Add(entityObject);
}
}
if (parent)
{
IComponent<TestObject>* pParent = static_cast<IComponent<TestObject>*>(parent);
pParent->Add(pComponent);
}
result = pComponent;
return result;
}
bool UpdateObject(
TEST_OBJECT object,
char* name,
char* image,
char* entity)
{
bool result = false;
IComponent<TestObject>* pComponent = null
;
if (!object)
{
return result;
}
pComponent = static_cast<IComponent<TestObject>*>(object);
pComponent->Object().SetImage (std::string(name));
pComponent->Object().SetIdent (std::string(image));
pComponent->Object().SetEntity (std::string(entity));
result = true;
return result;
}
bool DestroyObject(
TEST_OBJECT object)
{
bool result = false;
if (!object
) return result
;
IComponent<TestObject>*
pComponent = static_cast<IComponent<TestObject>*>(object)
;
delete pComponent
;
result = true
;
return result;
}
#endif
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
MSc in System Engineering from Tallinn Technical University, Estonia. Currently, I work in a hitech enterprise in Israel.