public void Execute() { _controller.Run(); PositionTakerController_Accessor acc = new PositionTakerController_Accessor( new PrivateObject(_controller)); Assert.AreEqual(acc.PTState.GetState(), PositionTakerState.WaitGotOrderNumber); S2_WaitGotOrderNum_PositionTakerState s2 = acc.PTState as S2_WaitGotOrderNum_PositionTakerState; POrder_UnittestUtil.GetFakeOrderNumber(s2.ThisTurnOrder); _controller.Run(); S3_WaitFewSec_PositionTakerState s3 = acc.PTState as S3_WaitFewSec_PositionTakerState; s3.ThisTurnOrder.Update(s2.ThisTurnOrder.ReqCount, s2.ThisTurnOrder.ReqPrice, true); // Done _controller.Run(); }
public void Execute() { _controller.Run(); PositionTakerController_Accessor acc = new PositionTakerController_Accessor( new PrivateObject(_controller)); Assert.AreEqual(acc.PTState.GetState(), PositionTakerState.WaitGotOrderNumber); S2_WaitGotOrderNum_PositionTakerState s2 = acc.PTState as S2_WaitGotOrderNum_PositionTakerState; POrder_UnittestUtil.GetFakeOrderNumber(s2.ThisTurnOrder); _controller.Run(); S3_WaitFewSec_PositionTakerState s3 = acc.PTState as S3_WaitFewSec_PositionTakerState; S3_WaitFewSec_PositionTakerState_Accessor s3Acc = new S3_WaitFewSec_PositionTakerState_Accessor( new PrivateObject(s3)); s3Acc._timer.SetAsForcedTimeOut(); String code = s2.ThisTurnOrder.Code; RawMarketData rmd = RmdManager.Ins().GetData(code); double price = rmd.BidPrice1; TickValue tv = ProductUtil.Ins().GetTick(code, price); if (s2.ThisTurnOrder.LongShort == TradingDirection.Long) { rmd.BidPrice1 = rmd.AskPrice1 + tv.UpTickValue; rmd.AskPrice1 = rmd.AskPrice1 + tv.UpTickValue * 2; } else { rmd.AskPrice1 = rmd.BidPrice1 - tv.DownTickValue; rmd.BidPrice1 = rmd.BidPrice1 - tv.DownTickValue * 2; } _controller.Run(); Assert.AreEqual(acc.PTState.GetState(), PositionTakerState.CancelRemains); _controller.Run(); S4_CancelRemains_PositionTakerState s4 = acc.PTState as S4_CancelRemains_PositionTakerState; POrder_UnittestUtil.CancelRemainsRightNow(s4.ThisTurnOrder); _controller.Run(); Assert.AreEqual(acc.PTState.GetState(), PositionTakerState.Request_Order); _controller.Run(); Assert.AreEqual(acc.PTState.GetState(), PositionTakerState.WaitGotOrderNumber); // 새로 주문한 오더를 본다. s2 = acc.PTState as S2_WaitGotOrderNum_PositionTakerState; POrder_UnittestUtil.GetFakeOrderNumber(s2.ThisTurnOrder); _controller.Run(); s2.ThisTurnOrder.Update(s2.ThisTurnOrder.ReqCount / 2, s2.ThisTurnOrder.ReqPrice, false); s3 = acc.PTState as S3_WaitFewSec_PositionTakerState; s3Acc = new S3_WaitFewSec_PositionTakerState_Accessor( new PrivateObject(s3)); s3Acc._timer.SetAsForcedTimeOut(); price = rmd.BidPrice1; tv = ProductUtil.Ins().GetTick(code, price); if (s2.ThisTurnOrder.LongShort == TradingDirection.Long) { rmd.BidPrice1 = rmd.AskPrice1 + tv.UpTickValue; rmd.AskPrice1 = rmd.AskPrice1 + tv.UpTickValue * 2; } else { rmd.AskPrice1 = rmd.BidPrice1 - tv.DownTickValue; rmd.BidPrice1 = rmd.BidPrice1 - tv.DownTickValue * 2; } _controller.Run(); Assert.AreEqual(acc.PTState.GetState(), PositionTakerState.CancelRemains); _controller.Run(); s4 = acc.PTState as S4_CancelRemains_PositionTakerState; POrder_UnittestUtil.CancelRemainsRightNow(s4.ThisTurnOrder); _controller.Run(); Assert.AreEqual(acc.PTState.GetState(), PositionTakerState.Request_Order); _controller.Run(); Assert.AreEqual(acc.PTState.GetState(), PositionTakerState.WaitGotOrderNumber); // 새로 주문한 오더를 본다. s2 = acc.PTState as S2_WaitGotOrderNum_PositionTakerState; POrder_UnittestUtil.GetFakeOrderNumber(s2.ThisTurnOrder); _controller.Run(); s2.ThisTurnOrder.Update(s2.ThisTurnOrder.ReqCount, s2.ThisTurnOrder.ReqPrice, true); _controller.Run(); Assert.AreEqual(acc.PTState.GetState(), PositionTakerState.Done); }