public void TestInitialize() { //Create stub communicator and pass it to the AMA commodity = 0; comm = new CommStubStaticReturn(); agent = new AdvancedAMA(3 + 1, 1000, comm); }
public void AdvancedAMAgatherInfoTestMethod() { //Setup communicatro stub List <MQCommodityWrapper> mqCommodityWrapper = new List <MQCommodityWrapper>(); List <MQReqWrapper> mqReqyWrapper = new List <MQReqWrapper>(); MQUser mqUser = new MQUser(); CommStubStaticReturn comm = new CommStubStaticReturn(); comm.qAllmarket = mqCommodityWrapper; comm.qAllrequests = mqReqyWrapper; comm.quser = mqUser; //Run AMA for a while AdvancedAMA agent = new AdvancedAMA(3, 1000, comm); agent.enable(true); System.Threading.Thread.Sleep(1500); agent.enable(false); //Verify if AMA has collected the info from the communicator stub Assert.IsNotNull(agent.commoditiesInfo); Assert.IsNotNull(agent.requestsInfo); Assert.IsNotNull(agent.userData); Assert.AreEqual(mqCommodityWrapper, agent.commoditiesInfo); Assert.AreEqual(mqReqyWrapper, agent.requestsInfo); Assert.AreEqual(mqUser, agent.userData); }
public void TestInitialize() { //Create stub communicator and pass it to the AMA commodity = 0; MQCommodity qmarket = new MQCommodity(); qmarket.ask = "10"; MQCommodityWrapper qmarketWrapper = new MQCommodityWrapper(); qmarketWrapper.info = qmarket; qmarketWrapper.id = commodity; List <MQCommodityWrapper> stubResponse = new List <MQCommodityWrapper>(); stubResponse.Add(qmarketWrapper); comm = new CommStubStaticReturn(); comm.qAllmarket = stubResponse; agent = new AdvancedAMA(3 + 1, 1000, comm); }
public void TestInitialize() { //Create stub communicator and pass it to the AMA commodity = 0; MQReq qmarket = new MQReq(); qmarketWrapper = new MQReqWrapper(); qmarketWrapper.id = 123456; qmarketWrapper.request = qmarket; List <MQReqWrapper> stubResponse = new List <MQReqWrapper>(); stubResponse.Add(qmarketWrapper); comm = new CommStubStaticReturn(); comm.qAllrequests = stubResponse; agent = new AdvancedAMA(3 + 1, 1000, comm); }
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); }
public AlgoCountProcess(AdvancedAMA agent, ICommunicator comm, int commodity) : base(agent, comm, commodity) { this.setAction(new AlgoCountAction()); }