public bool runAction(AlgoProcess process)
 {
     if (process is AlgoCountProcess)
     {
         AlgoCountProcess countProcess = (AlgoCountProcess)process;
         countProcess.count += 1;
         Trace.WriteLine("Process activation #" + countProcess.count);
         return(true);
     }
     else
     {
         return(false);
     }
 }
        public void AskCompareTestFalse()
        {
            //Create process that will count each time the AlgoAskCompare condition is "true"
            AlgoCountProcess testProcess = new AlgoCountProcess(agent, comm, commodity);

            testProcess.addCondition(new AlgoAskCompare(10 - 1));
            agent.add(testProcess);

            //Run AMA once
            agent.enable(true);
            System.Threading.Thread.Sleep(1500);
            agent.enable(false);

            //AMA ran once but condition is not met - count should be "0"
            Assert.AreEqual(0, testProcess.count);
        }
        public void TestAdvancedAMATimer()
        {
            //setup
            int maxReq        = 10;
            int amaUpdateCost = 3;
            int interval      = 1000;

            AdvancedAMA      amaTest   = new AdvancedAMA(maxReq, interval, new CommStubStaticReturn());
            AlgoCountProcess testLogic = new AlgoCountProcess(amaTest, new CommStubStaticReturn(), 0);

            amaTest.add(testLogic);
            amaTest.enable(true);

            //interval*2 because the ama waits the interval once enabled
            //to run the first time
            System.Threading.Thread.Sleep(interval * 2);

            amaTest.enable(false);

            Task.WaitAll();
            Assert.AreEqual(maxReq - amaUpdateCost, testLogic.count);
        }