public void AskCompareTestTrue() { //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 - count should be "1" Assert.AreEqual(1, testProcess.count); }
public void HasNoActiveRequestTestTrue() { //Create process that will count each time the AlgoAskCompare condition is "true" AlgoCountProcess testProcess = new AlgoCountProcess(agent, comm, commodity); testProcess.addCondition(new HasNoActiveRequest()); testProcess.requestID = -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(1, testProcess.count); }
public void MomentumIncreaseTrue() { //Create process that will count each time the AlgoAskCompare condition is "true" AlgoCountProcess testProcess = new AlgoCountProcess(agent, comm, commodity); HistoryDalImplementation sqlStub = new SQLserverMomentumStub(true); MomentumIncrease momentumIncreaseCond = new MomentumIncrease(1, 10, 20); momentumIncreaseCond.sql = sqlStub; testProcess.addCondition(momentumIncreaseCond); agent.add(testProcess); //Run AMA once agent.enable(true); System.Threading.Thread.Sleep(1500); agent.enable(false); //AMA ran once - count should be "1" Assert.AreEqual(1, 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); }