/** @test verify the Handling pattern API: undo a command */
 void
 checkUndo (PCommandImpl com)
   {
     CHECK (com);
     CHECK (com->canExec());
     CHECK (com->canUndo());
     
     CHECK (command1::check_ > 0);
     
     HaPatt ePatt = HandlingPattern::get(TEST_PATTERN);
     ExecResult res = ePatt.undo (*com, TEST_CMD);
     
     CHECK (res);
     CHECK (command1::check_ == 0);
   }
Ejemplo n.º 2
0
 void
 checkExec (PCommandImpl com)
   {
     CHECK (com);
     CHECK (!com->canExec());
     
     typedef Types<int> ArgType;
     const int ARGU (1 + rand() % 1000);
     Tuple<ArgType> tuple(ARGU);
     TypedArguments<Tuple<ArgType> > arg(tuple);
     com->setArguments(arg);
     
     CHECK (com->canExec());
     CHECK (!com->canUndo());
     command1::check_ = 0;
     
     HaPatt patt = HandlingPattern::get(TEST_PATTERN);
     ExecResult res = patt.invoke(*com, TEST_CMD);
     
     CHECK (res);
     CHECK (ARGU == command1::check_);
     CHECK (com->canUndo());
   }
 /** @test use custom implementation of the HandlingPattern interface,
  *        rigged to verify the functions are actually invoked.
  */
 void
 useCustomHandler (PCommandImpl com)
   {
     CustomHandler specialHandler;
     
     CHECK (com->canExec());
     CHECK (not specialHandler.invokedExec());
     
     specialHandler.exec (*com, TEST_CMD);
     CHECK (    specialHandler.invokedExec());
     CHECK (not specialHandler.invokedUndo());
     
     specialHandler.undo (*com, TEST_CMD);
     CHECK (    specialHandler.invokedExec());
   }