Index: src/unittests/CacheableTest.cpp
===================================================================
--- src/unittests/CacheableTest.cpp	(revision ac9b567dcfceb87f9ec160392d8deff13fa247d5)
+++ src/unittests/CacheableTest.cpp	(revision ac9b567dcfceb87f9ec160392d8deff13fa247d5)
@@ -0,0 +1,105 @@
+/*
+ * CacheableTest.cpp
+ *
+ *  Created on: Feb 2, 2010
+ *      Author: crueger
+ */
+
+#include "CacheableTest.hpp"
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+
+#include <boost/bind.hpp>
+
+#include "Patterns/Cacheable.hpp"
+
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION( CacheableTest );
+
+class threeNumbers : public Observable {
+public:
+  bool hasRecalced;
+  int x;
+  int y;
+  int z;
+
+  void setX(int _x){
+    START_OBSERVER;;
+    x = _x;
+    FINISH_OBSERVER;
+  }
+
+  void setY
+  (int _y){
+    START_OBSERVER;;
+    y = _y;
+    FINISH_OBSERVER;
+  }
+
+  void setZ(int _z){
+    START_OBSERVER;;
+    z = _z;
+    FINISH_OBSERVER;
+  }
+
+  int calcSum(){
+    hasRecalced = true;
+    return x+y+z;
+  }
+
+  threeNumbers(int _x,int _y, int _z) :
+    sum(this,boost::bind(&threeNumbers::calcSum,this)),
+    x(_x),y(_y),z(_z),
+    hasRecalced(false)
+  {}
+
+  Cacheable<int> sum;
+};
+
+
+
+
+void CacheableTest::setUp(){
+  numbers = new threeNumbers(1,2,3);
+}
+
+void CacheableTest::tearDown(){
+  delete numbers;
+}
+
+void CacheableTest::doesRecalcTest()
+{
+  CPPUNIT_ASSERT_EQUAL( 6, *(numbers->sum));
+  CPPUNIT_ASSERT_EQUAL( true, numbers->hasRecalced);
+  numbers->hasRecalced=false;
+  numbers->setX(4);
+  CPPUNIT_ASSERT_EQUAL( false, numbers->hasRecalced);
+  CPPUNIT_ASSERT_EQUAL( 9, *(numbers->sum));
+  CPPUNIT_ASSERT_EQUAL( true, numbers->hasRecalced);
+}
+
+
+
+/********************************************** Main routine **************************************/
+
+int main(int argc, char **argv)
+{
+  // Get the top level suite from the registry
+  CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
+
+  // Adds the test to the list of test to run
+  CppUnit::TextUi::TestRunner runner;
+  runner.addTest( suite );
+
+  // Change the default outputter to a compiler error format outputter
+  runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(),
+                                                       std::cerr ) );
+  // Run the tests.
+  bool wasSucessful = runner.run();
+
+  // Return error code 1 if the one of test failed.
+  return wasSucessful ? 0 : 1;
+};
+
Index: src/unittests/CacheableTest.hpp
===================================================================
--- src/unittests/CacheableTest.hpp	(revision ac9b567dcfceb87f9ec160392d8deff13fa247d5)
+++ src/unittests/CacheableTest.hpp	(revision ac9b567dcfceb87f9ec160392d8deff13fa247d5)
@@ -0,0 +1,31 @@
+/*
+ * CacheableTest.hpp
+ *
+ *  Created on: Feb 2, 2010
+ *      Author: crueger
+ */
+
+#ifndef CACHEABLETEST_HPP_
+#define CACHEABLETEST_HPP_
+
+#include <cppunit/extensions/HelperMacros.h>
+
+
+// stub classes
+class threeNumbers;
+
+class CacheableTest :  public CppUnit::TestFixture
+{
+  CPPUNIT_TEST_SUITE( CacheableTest );
+  CPPUNIT_TEST ( doesRecalcTest );
+  CPPUNIT_TEST_SUITE_END();
+
+public:
+  void setUp();
+  void tearDown();
+
+  void doesRecalcTest();
+  threeNumbers *numbers;
+};
+
+#endif /* CACHEABLETEST_HPP_ */
Index: src/unittests/Makefile.am
===================================================================
--- src/unittests/Makefile.am	(revision d5f2169f6714e2ce2f8c4379d8e1059f7a6c430d)
+++ src/unittests/Makefile.am	(revision ac9b567dcfceb87f9ec160392d8deff13fa247d5)
@@ -28,4 +28,5 @@
   VectorUnitTest \
   ObserverTest \
+  CacheableTest \
   ${MENUTESTS}  
     
@@ -100,4 +101,7 @@
 ObserverTest_LDADD = ../libmolecuilder.a
 
+CacheableTest_SOURCES = CacheableTest.cpp CacheableTest.hpp
+CacheableTest_LDADD = ../libmolecuilder.a
+
 #AUTOMAKE_OPTIONS = parallel-tests
 
