public IMarketResponse SendQueryMarketRequest(int commodity) { //example: {"ask": 9999999, "bid": 0} Trace.WriteLine(String.Format("Sent Commodity Query Request: commodity: {0}", commodity)); MQCommodity output = new MQCommodity(); output.ask = "10"; output.bid = "1"; return(output); }
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 BuyTestFullProcess() { //arrange MBuySell buy = new MBuySell(); buy.id = "666"; MQReq query = new MQReq(); MQCommodity market = new MQCommodity(); market.ask = "1"; MarketException excp = new MarketException(); CommStubStaticReturn comm = new CommStubStaticReturn(buy, null, null, excp, market, null, null, null); BuyProcess testProcess = new BuyProcess(true, comm, 1, 1, 1, 1); //initial assert Assert.AreEqual(testProcess.currIndex, 0); Assert.AreEqual(testProcess.queue, LogicQueue.first); //act1 object output = testProcess.run(); //assert1 Assert.AreEqual(testProcess.currIndex, 1); Assert.AreEqual(testProcess.queue, LogicQueue.first); //act2 output = testProcess.run(); //assert2 Assert.AreEqual(testProcess.currIndex, 2); Assert.AreEqual(testProcess.queue, LogicQueue.first); //update communicator stub comm = new CommStubStaticReturn(buy, null, null, query, market, null, null, null); testProcess.comm = comm; //act3 output = testProcess.run(); //assert3 Assert.AreEqual(testProcess.currIndex, 0); Assert.AreEqual(testProcess.queue, LogicQueue.last); //act4 output = testProcess.run(); //assert4 Assert.AreEqual(testProcess.currIndex, 0); Assert.AreEqual(testProcess.queue, LogicQueue.last); }
public void SellTestFullProcess() { //arrange MBuySell sell = new MBuySell(); sell.id = "666"; MQReq query = new MQReq(); MQCommodity market = new MQCommodity(); market.bid = "1"; MarketException excp = new MarketException(); //create valid user query response MQUser user = new MQUser(); user.commodities = new Dictionary <String, int>(); user.commodities.Add("1", 3); int test = user.commodities["1"]; CommStubStaticReturn comm = new CommStubStaticReturn(null, sell, null, excp, market, user, null, null); SellProcess testProcess = new SellProcess(true, comm, 1, 1, 1, 1); //initial assert Assert.AreEqual(testProcess.currIndex, 0); Assert.AreEqual(testProcess.queue, LogicQueue.first); //act1 object output = testProcess.run(); //assert1 Assert.AreEqual(testProcess.currIndex, 1); Assert.AreEqual(testProcess.queue, LogicQueue.first); //act2 output = testProcess.run(); //assert2 Assert.AreEqual(testProcess.currIndex, 2); Assert.AreEqual(testProcess.queue, LogicQueue.first); //act3 output = testProcess.run(); //assert3 Assert.AreEqual(testProcess.currIndex, 3); Assert.AreEqual(testProcess.queue, LogicQueue.first); //act4 output = testProcess.run(); //assert4 Assert.AreEqual(testProcess.currIndex, 0); Assert.AreEqual(testProcess.queue, LogicQueue.last); //update communicator stub comm = new CommStubStaticReturn(null, sell, null, query, market, user, null, null); testProcess.comm = comm; //act5 output = testProcess.run(); //assert5 Assert.AreEqual(testProcess.currIndex, 0); Assert.AreEqual(testProcess.queue, LogicQueue.last); }