Ignore:
Timestamp:
Jan 6, 2011, 12:22:12 PM (15 years ago)
Author:
Frederik Heber <heber@…>
Children:
9f39db
Parents:
d76c105
Message:

PrototypeFactory now allows for replacing prototypes.

  • if a prototype can only be manipulated via its constructor, it is essential for the factory to allow for changing prototypes in a controlled manner. All the functions on prototypes are protected, hence only friends may get access.
  • Library version is now 3:1:1, API version is 1.0.6.
Location:
src/Patterns/unittests
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/Patterns/unittests/PrototypeFactoryUnitTest.cpp

    rd76c105 r567640  
    183183  CPPUNIT_ASSERT( rndA->getcount() == rndA_3->getcount() );
    184184}
     185
     186void PrototypeFactoryTest::installPrototypetest()
     187{
     188  Prototype< teststubs::Aclass> *newprototype = new Prototype< teststubs::Aclass> ();
     189  newprototype->setcount(1);
     190  PrototypeFactoryStub::getInstance().installPrototype(newprototype, std::string("Aclass"));
     191  newprototype = NULL;
     192
     193  IPrototype *rndA_1 = PrototypeFactoryStub::getInstance().getProduct(std::string("Aclass"));
     194  CPPUNIT_ASSERT( 1 == rndA_1->getcount() );
     195
     196  rndA_1->count();
     197  CPPUNIT_ASSERT( 2 == rndA_1->getcount() );
     198
     199  IPrototype *rndA_2 = PrototypeFactoryStub::getInstance().getProduct(std::string("Aclass"));
     200  CPPUNIT_ASSERT( 1 == rndA_2->getcount() );
     201  CPPUNIT_ASSERT( rndA_1->getcount() != rndA_2->getcount() );
     202}
  • src/Patterns/unittests/PrototypeFactoryUnitTest.hpp

    rd76c105 r567640  
    2727  CPPUNIT_TEST ( Individualitytest );
    2828  CPPUNIT_TEST ( PrototypeManipulatortest );
     29  CPPUNIT_TEST ( installPrototypetest );
    2930  CPPUNIT_TEST_SUITE_END();
    3031
     
    3940  void Individualitytest();
    4041  void PrototypeManipulatortest();
     42  void installPrototypetest();
    4143
    4244private:
  • src/Patterns/unittests/stubs/CloneStub.hpp

    rd76c105 r567640  
    3939
    4040    /**
    41      * Test is friend such that it can access protected cstor.
     41     * Tests are friend such that it can access protected cstor.
    4242     */
    4343    friend class CloneTest;
     44    friend class PrototypeFactoryTest;
    4445
    4546protected:
Note: See TracChangeset for help on using the changeset viewer.