Index: ThirdParty/CodePatterns/src/Observer/unittests/GraveyardUnitTest.cpp
===================================================================
--- ThirdParty/CodePatterns/src/Observer/unittests/GraveyardUnitTest.cpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
+++ ThirdParty/CodePatterns/src/Observer/unittests/GraveyardUnitTest.cpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
@@ -0,0 +1,174 @@
+/*
+ * Project: CodePatterns
+ * Copyright (C)  2013 Frederik Heber. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+
+/*
+ * GraveyardUnitTest.cpp
+ *
+ *  Created on: Sep 05, 2013
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+#include <set>
+
+#include "CodePatterns/Assert.hpp"
+
+#include <iostream>
+
+#include "stubs/ObserverStub.hpp"
+#include "CodePatterns/Observer/Graveyard.hpp"
+#include "CodePatterns/Observer/Notification.hpp"
+#include "CodePatterns/Observer/ObserverLog.hpp"
+
+#include "GraveyardUnitTest.hpp"
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
+
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION( GraveyardUnitTest );
+
+/******************* Test stubs ************************/
+
+
+/******************* actuall tests ***************/
+
+void GraveyardUnitTest::setUp() {
+  ASSERT_DO(Assert::Throw);
+#ifdef LOG_OBSERVER
+  ObserverLog::getInstance().enableLogging();
+#endif
+
+  graveyard = new Graveyard;
+  observer1 = new UpdateCountObserver();
+  observer2 = new UpdateCountObserver();
+  observer3 = new UpdateCountObserver();
+  observer4 = new UpdateCountObserver();
+}
+
+void GraveyardUnitTest::tearDown() {
+  delete observer1;
+  delete observer2;
+  delete observer3;
+  delete observer4;
+#ifdef LOG_OBSERVER
+  ObserverLog::getInstance().disableLogging();
+#endif
+  delete graveyard;
+}
+
+void GraveyardUnitTest::Zombie_soloTest()
+{
+  observerLog().enableLogging();
+
+  // test with unobserved Observable
+  Observable *simpleObservable1 = new SimpleObservable();
+
+  graveyard->turnZombie( simpleObservable1);
+  CPPUNIT_ASSERT( graveyard->graveyard.size() == 0);
+
+  observerLog().disableLogging();
+}
+
+void GraveyardUnitTest::Zombie_oneTest()
+{
+  observerLog().enableLogging();
+
+  // test with one Observer
+  SimpleObservable *simpleObservable1 = new SimpleObservable();
+  Observable *_observable = simpleObservable1;
+
+  simpleObservable1->signOn(observer1);
+  graveyard->turnZombie(_observable);
+  simpleObservable1->signOff(observer1);
+  CPPUNIT_ASSERT( graveyard->graveyard.size() == 0);
+
+  observerLog().disableLogging();
+}
+
+void GraveyardUnitTest::Zombie_manyTest()
+{
+  observerLog().enableLogging();
+
+  // test with some more Observers
+  SimpleObservable *simpleObservable1 = new SimpleObservable();
+  Observable *_observable = simpleObservable1;
+
+  // create some observer noise
+  simpleObservable1->signOn(observer1);
+  simpleObservable1->signOn(observer2);
+  simpleObservable1->signOn(observer3);
+  simpleObservable1->signOn(observer4);
+
+  // turn zombie
+  graveyard->turnZombie(_observable);
+
+  // remove the noise again (in mixed order)
+  CPPUNIT_ASSERT( graveyard->graveyard.size() == 1);
+  CPPUNIT_ASSERT_EQUAL( (size_t)4, simpleObservable1->getNumberOfObservers());
+  simpleObservable1->signOff(observer3);
+  CPPUNIT_ASSERT( graveyard->graveyard.size() == 1);
+  CPPUNIT_ASSERT_EQUAL( (size_t)3, simpleObservable1->getNumberOfObservers());
+  simpleObservable1->signOff(observer2);
+  CPPUNIT_ASSERT( graveyard->graveyard.size() == 1);
+  CPPUNIT_ASSERT_EQUAL( (size_t)2, simpleObservable1->getNumberOfObservers());
+  simpleObservable1->signOff(observer4);
+  CPPUNIT_ASSERT( graveyard->graveyard.size() == 1);
+  CPPUNIT_ASSERT_EQUAL( (size_t)1, simpleObservable1->getNumberOfObservers());
+  simpleObservable1->signOff(observer1);
+  CPPUNIT_ASSERT( graveyard->graveyard.size() == 0);
+  CPPUNIT_ASSERT_EQUAL( (size_t)0, simpleObservable1->getNumberOfObservers());
+
+  observerLog().disableLogging();
+}
+
+void GraveyardUnitTest::Zombie_notificationsTest()
+{
+  observerLog().enableLogging();
+
+  // test with an observable with notifications
+  NotificationObservable *notificationObservable = new NotificationObservable();
+  Observable *_observable = notificationObservable;
+
+  // create some observer noise
+  notificationObservable->signOn(observer1);
+  notificationObservable->signOn(observer2);
+  notificationObservable->signOn(observer2, NotificationObservable::Operation1Notify);
+  notificationObservable->signOn(observer3, NotificationObservable::Operation1Notify);
+  notificationObservable->signOn(observer4, NotificationObservable::Operation2Notify);
+
+  // turn zombie
+  graveyard->turnZombie(_observable);
+
+  // remove the noise again (in mixed order)
+  CPPUNIT_ASSERT( graveyard->graveyard.size() == 1);
+  CPPUNIT_ASSERT_EQUAL( (size_t)5, notificationObservable->getNumberOfObservers());
+  notificationObservable->signOff(observer3, NotificationObservable::Operation1Notify);
+  CPPUNIT_ASSERT( graveyard->graveyard.size() == 1);
+  CPPUNIT_ASSERT_EQUAL( (size_t)4, notificationObservable->getNumberOfObservers());
+  notificationObservable->signOff(observer2, NotificationObservable::Operation1Notify);
+  CPPUNIT_ASSERT( graveyard->graveyard.size() == 1);
+  CPPUNIT_ASSERT_EQUAL( (size_t)3, notificationObservable->getNumberOfObservers());
+  notificationObservable->signOff(observer2);
+  CPPUNIT_ASSERT( graveyard->graveyard.size() == 1);
+  CPPUNIT_ASSERT_EQUAL( (size_t)2, notificationObservable->getNumberOfObservers());
+  notificationObservable->signOff(observer4, NotificationObservable::Operation2Notify);
+  CPPUNIT_ASSERT( graveyard->graveyard.size() == 1);
+  CPPUNIT_ASSERT_EQUAL( (size_t)1, notificationObservable->getNumberOfObservers());
+  notificationObservable->signOff(observer1);
+  CPPUNIT_ASSERT( graveyard->graveyard.size() == 0);
+  CPPUNIT_ASSERT_EQUAL( (size_t)0, notificationObservable->getNumberOfObservers());
+
+  observerLog().disableLogging();
+}
