Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

TestCaseDummyManoeuvre_1.cpp

00001 // 00002 // Copyright 2004 P&P Software GmbH - All Rights Reserved 00003 // 00004 // TestCaseDummyManoeuvre_1.cpp 00005 // 00006 // Version 1.1 00007 // Date 08.05.03 00008 // Author R. Totaro 00009 00010 #include "TestCaseDummyManoeuvre_1.h" 00011 #include "../GeneralInclude/ClassId.h" 00012 #include "../GeneralInclude/Constants.h" 00013 #include "../GeneralInclude/CompilerSwitches.h" 00014 #include "../Manoeuvre/DC_DummyManoeuvre.h" 00015 00016 TestCaseDummyManoeuvre_1::TestCaseDummyManoeuvre_1(void) : 00017 TestCaseWithEvtCheck(ID_DUMMYMANOEUVRE*10+1,"TestCaseDummyManoeuvre_1") 00018 { 00019 return; 00020 } 00021 00022 void TestCaseDummyManoeuvre_1::runTestCase() 00023 { 00024 DC_DummyManoeuvre *pDM =new DC_DummyManoeuvre(); 00025 const unsigned int nEvt=getNumberOfEvents(); 00026 00027 // Verify correctness of class identifier 00028 if (pDM->getClassId()!=ID_DUMMYMANOEUVRE) { 00029 setTestResult(TEST_FAILURE,"Wrong class identifier"); 00030 return; 00031 } 00032 00033 // Newly created manoeuvres should be enabled 00034 if (!pDM->isEnabled()) { 00035 setTestResult(TEST_FAILURE,"Manoeuvre not enabled"); 00036 return; 00037 } 00038 00039 // Check value of continuation check code 00040 if ( pDM->getContinuationCheckCode()!=0 ) { 00041 setTestResult(TEST_FAILURE,"Continuation check code is incorrect"); 00042 return; 00043 } 00044 00045 // Newly created manoeuvres should not be in use 00046 if (pDM->isInUse()) { 00047 setTestResult(TEST_FAILURE,"Wrong value of inUse flag (true)"); 00048 return; 00049 } 00050 00051 // Newly created manoeuvres should not be executing 00052 if (pDM->isExecuting()) { 00053 setTestResult(TEST_FAILURE,"Wrong value of isExecuting flag (true)"); 00054 return; 00055 } 00056 00057 // Newly created manoeuvres should not be suspended 00058 if (pDM->isSuspended()) { 00059 setTestResult(TEST_FAILURE,"Wrong value of isSuspended flag (true)"); 00060 return; 00061 } 00062 00063 // Verify that the enable flag can be modified 00064 pDM->setEnabled(false); 00065 if (pDM->isEnabled()) { 00066 setTestResult(TEST_FAILURE,"Failed to disable the manoeuvre"); 00067 return; 00068 } 00069 00070 // Verify that the inUse flag can be modified 00071 pDM->setInUse(true); 00072 if (!pDM->isInUse()) { 00073 setTestResult(TEST_FAILURE,"Failed to change the inUse flag"); 00074 return; 00075 } 00076 00077 // Verify that the isSuspended flag can be modified 00078 pDM->setIsSuspended(true); 00079 if (!pDM->isSuspended()) { 00080 setTestResult(TEST_FAILURE,"Failed to change the isSuspended flag"); 00081 return; 00082 } 00083 00084 // Verify the event reporting 00085 if (!verifyLatestEvent(nEvt+1,EVT_MAN_SUSPENDED)) 00086 return; 00087 00088 // Resume manoeuvre and check correct event reporting 00089 pDM->setIsSuspended(false); 00090 if (!verifyLatestEvent(nEvt+2,EVT_MAN_RESUMED)) 00091 return; 00092 00093 // Verify that a disable manoeuvre cannot be started 00094 if (pDM->canStart()!=MAN_CANNOT_START) { 00095 setTestResult(TEST_FAILURE,"Disabled manoeuvre can be started"); 00096 return; 00097 } 00098 00099 // Now, let's check the opposite situation 00100 pDM->setEnabled(true); 00101 if (pDM->canStart()!=MAN_CAN_START) { 00102 setTestResult(TEST_FAILURE,"Enabled manoeuvre cannot be started"); 00103 return; 00104 } 00105 00106 // Let's start the manoeuvre 00107 pDM->initialize(); 00108 pDM->doContinue(); 00109 00110 // Verify that the manoeuvre is executing 00111 if (!pDM->isExecuting()) { 00112 setTestResult(TEST_FAILURE,"Manoeuvre cannot be started"); 00113 return; 00114 } 00115 00116 // Verify the event reporting 00117 if (!verifyLatestEvent(nEvt+3,EVT_MAN_STARTED)) 00118 return; 00119 00120 // Check that the manoeuvre can continue 00121 if (!pDM->canContinue()) { 00122 setTestResult(TEST_FAILURE,"canContinue() reports wrong status"); 00123 return; 00124 } 00125 00126 // Verify the termination check 00127 if (!pDM->isFinished()) { 00128 setTestResult(TEST_FAILURE,"Failed termination check"); 00129 return; 00130 } 00131 00132 // The manoeuvre is aborted and the execution status and event report are verified 00133 pDM->abort(); 00134 if (pDM->isExecuting()) { 00135 setTestResult(TEST_FAILURE,"Manoeuvre cannot be aborted"); 00136 return; 00137 } 00138 00139 if (!verifyLatestEvent(nEvt+4,EVT_MAN_ABORTED)) 00140 return; 00141 00142 // Let's now do a full initialization/execution/termination cycle 00143 pDM->initialize(); 00144 pDM->doContinue(); 00145 pDM->terminate(); 00146 if (pDM->isExecuting()) { 00147 setTestResult(TEST_FAILURE,"Failed to terminate the manoeuvre"); 00148 return; 00149 } 00150 00151 // Verify the event reporting 00152 // The initialize()/doContinue() pair generates an event. 00153 if (!verifyLatestEvent(nEvt+6,EVT_MAN_TERMINATED)) 00154 return; 00155 00156 setTestResult(TEST_SUCCESS,"Test Successful"); 00157 return; 00158 }
Copyright 2003 P&P Software GmbH - All Rights Reserved