Click here to Skip to main content
15,897,187 members
Articles / Desktop Programming / MFC

Unit Test's Reporter

Rate me:
Please Sign up or sign in to vote.
4.86/5 (28 votes)
19 Feb 2006CPOL11 min read 64.8K   2.8K   58  
The article describes an application built to visualise testing processes for the unit test framework of CppUnitLite.
#ifndef	_WINDOWS_ENVIRONMENT_OBJECT_EXT_H
#define	_WINDOWS_ENVIRONMENT_OBJECT_EXT_H

#include	"Composite.h"
#include	"EnvironmentObject.h"
#include	"WinEnvironment.h"
#include	"WinEnvironmentObjectCreator.h"

#pragma warning(disable : 4482)

template <typename T>
class	WindowsEnvironmentObjectExt : public IEnvironmentObject<T>
{
public:
	WindowsEnvironmentObjectExt(IComponent<T>* pComponent)
	:	 IEnvironmentObject<T>(pComponent)
	{
	}

	virtual	~WindowsEnvironmentObjectExt()
	{
		if (LinkedObject())
		{
			IComponent<T>*	pComponent	= LinkedObject();
			IEnvironment<T>*	pEnvironment	= pComponent->Environment();
			if (pEnvironment)
			{
				WindowsEnvironment<T>*
					mockEnvironment	= dynamic_cast<WindowsEnvironment<T>*>(pEnvironment);
				if (mockEnvironment)
				{
					mockEnvironment->TreeControl()->DeleteItem(entity_);
				}
			}
		}
	}

	virtual void Update	()
	{
		int		regImage	= 0,
				selImage	= 0
		;
		if (pComponent_->Object().CurrentState() == TestObject::State::UpdateImage)
		{
			if (pComponent_->Object().Image() == std::string("Error"))
			{
				regImage	= 0;
				selImage	= 1;
			}
			else
			if (pComponent_->Object().Image() == std::string("Success"))
			{
				regImage	= 2;
				selImage	= 3;
			}
			else
			{
				regImage	= 4;
				selImage	= 5;
			}
			dynamic_cast<WindowsEnvironment<T>*>(
				LinkedObject()->Environment())->TreeControl()->SetItemImage(entity_,regImage,selImage);
		}
		else
		if (pComponent_->Object().CurrentState() == TestObject::State::UpdateEntity)
		{
		//	if (logger_)
		//	logger_->Add(EasyString(_envObjectUpdateExtEntity.c_str()));
		}
		else
		if (pComponent_->Object().CurrentState() == TestObject::State::UpdateIdent)
		{
		//	if (logger_)
		//	logger_->Add(EasyString(_envObjectUpdateExtIdent.c_str()));
		}
		else
		if (pComponent_->Object().CurrentState() == TestObject::State::UpdateType)
		{
		//	if (logger_)
		//	logger_->Add(EasyString(_envObjectUpdateExtType.c_str()));
		}
	}

	HTREEITEM	Entity		()	{ return entity_; }
	void		SetEntity	(HTREEITEM entity )	{ entity_ = entity; }

protected:
	HTREEITEM	entity_;
};

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

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
Israel Israel
MSc in System Engineering from Tallinn Technical University, Estonia. Currently, I work in a hitech enterprise in Israel.

Comments and Discussions