void TestSweeper_BondArb_NR_Running(MonitorEnter_BondArb_Accessor me, Sweeper_BondArb sweeper)
        {
            Sweeper_BondArb_Accessor accessor = new Sweeper_BondArb_Accessor(new PrivateObject(sweeper));
            Assert.AreEqual(accessor._bDone, false);

            SweepUnitTemplate longSweepUnitTemplate = accessor._sweepUnitLong;
            SweepUnitTemplate_Accessor longSweepUnitTemplate_Accessor = new SweepUnitTemplate_Accessor(new PrivateObject(longSweepUnitTemplate));
            SweepUnitContext_Bond_Long longContext = longSweepUnitTemplate_Accessor.Context as SweepUnitContext_Bond_Long;
            SweepUnitContext_Bond_Long_Accessor longContext_Accessor = new SweepUnitContext_Bond_Long_Accessor(new PrivateObject(longContext));

            SweepUnitTemplate shortSweepUnitTemplate = accessor._sweepUnitShort;
            SweepUnitTemplate_Accessor shortSweepUnitTemplate_Accessor = new SweepUnitTemplate_Accessor(new PrivateObject(shortSweepUnitTemplate));
            SweepUnitContext_Bond_Short shortContext = shortSweepUnitTemplate_Accessor.Context as SweepUnitContext_Bond_Short;
            SweepUnitContext_Bond_Short_Accessor shortContext_Accessor = new SweepUnitContext_Bond_Short_Accessor(new PrivateObject(shortContext));

            // 1. 소액 25,000,000 체결
            POrder initLongOrder0 = longContext_Accessor._initOrders[0];
            // 주문번호 0
            initLongOrder0.OrderNumber = 0;
            initLongOrder0.Update(25 * CommonConst._1_000_000, 5000, false);
            Assert.AreEqual(initLongOrder0.ShortCutTargetOfContractCallBack.Contract_CallBack(initLongOrder0), true);

            Assert.AreEqual(shortSweepUnitTemplate.GetSignedPossibleContractCount(), (-1) * 25000000);
            Assert.AreEqual(shortContext_Accessor.RealOrdersShort.Count, 1);

            initLongOrder0.Update(50 * CommonConst._1_000_000, 5000, false);
            Assert.AreEqual(initLongOrder0.ShortCutTargetOfContractCallBack.Contract_CallBack(initLongOrder0), true);

            Assert.AreEqual(shortSweepUnitTemplate.GetSignedPossibleContractCount(), (-1) * 50000000);
            Assert.AreEqual(shortContext_Accessor.RealOrdersShort.Count, 2);

            initLongOrder0.Update(200 * CommonConst._1_000_000, 5000, false);
            Assert.AreEqual(initLongOrder0.ShortCutTargetOfContractCallBack.Contract_CallBack(initLongOrder0), true);

            Assert.AreEqual(shortSweepUnitTemplate.GetSignedPossibleContractCount(), (-1) * 200 * CommonConst._1_000_000);
            Assert.AreEqual(shortContext_Accessor.RealOrdersShort.Count, 3);

            POrder balanceOrder0 = shortContext_Accessor.RealOrdersShort[0];
            POrder balanceOrder1 = shortContext_Accessor.RealOrdersShort[1];
            POrder balanceOrder2 = shortContext_Accessor.RealOrdersShort[2];

            balanceOrder0.OrderNumber = 0;
            balanceOrder1.OrderNumber = 0;
            balanceOrder2.OrderNumber = 0;

            // balance order
            Assert.AreEqual(balanceOrder0.Code, _kDoosanCode_Retail);
            Assert.AreEqual(balanceOrder0.LongShort, TradingDirection.Short);
            Assert.AreEqual(balanceOrder0.ReqCount, 25 * CommonConst._1_000_000);
            Assert.AreEqual(balanceOrder0.ReqPrice, 15000);

            // balance order 25,000,000 체결시킨다
            balanceOrder0.Update(25 * CommonConst._1_000_000, 15000, true);

            // 4. Sweep 테스트를 진행한다.

            longSweepUnitTemplate_Accessor.CurState = SweepUnitTemplate.StateEnum._2_WaitUntilGotAllOrderNumber;
            shortSweepUnitTemplate_Accessor.CurState = SweepUnitTemplate.StateEnum._2_WaitUntilGotAllOrderNumber;

            Assert.AreEqual(sweeper.Run(), false);

            Assert.AreEqual(longSweepUnitTemplate_Accessor.CurState, SweepUnitTemplate.StateEnum._3_WaitUntilCancelAllOrders);
            Assert.AreEqual(shortSweepUnitTemplate_Accessor.CurState, SweepUnitTemplate.StateEnum._3_WaitUntilCancelAllOrders);

            initLongOrder0.UpdateCancelMessage(initLongOrder0.ReqCount - initLongOrder0.ContractedCount);
            balanceOrder0.UpdateCancelMessage(balanceOrder0.ReqCount - balanceOrder0.ContractedCount);
            balanceOrder1.UpdateCancelMessage(balanceOrder1.ReqCount - balanceOrder1.ContractedCount);
            balanceOrder2.UpdateCancelMessage(balanceOrder2.ReqCount - balanceOrder2.ContractedCount);

            Assert.AreEqual(sweeper.Run(), false);

            Assert.AreEqual(longSweepUnitTemplate_Accessor.CurState, SweepUnitTemplate.StateEnum._4_WaitingRunSign);
            Assert.AreEqual(shortSweepUnitTemplate_Accessor.CurState, SweepUnitTemplate.StateEnum._4_WaitingRunSign);

            Assert.AreEqual(longContext_Accessor.CurSignedTargetCount, 300 * CommonConst._1_000_000);
            Assert.AreEqual(shortContext_Accessor.CurSignedTargetCount, (-1) * 300 * CommonConst._1_000_000);

            //Resume
            Assert.AreEqual(sweeper.Run(), false);

            Assert.AreEqual(longContext_Accessor.CurSignedTargetCount, 200 * CommonConst._1_000_000);
            Assert.AreEqual(shortContext_Accessor.CurSignedTargetCount, (-1) * 200 * CommonConst._1_000_000);

            Assert.AreEqual(longSweepUnitTemplate_Accessor.CurState, SweepUnitTemplate.StateEnum._7_Done);

            POrder sweepOrder = shortContext_Accessor.RealOrdersShort[3];

            Assert.AreEqual(sweepOrder.ReqCount, 175 * CommonConst._1_000_000);
            Assert.AreEqual(sweepOrder.Code, _kDoosanCode_Retail);
            Assert.AreEqual(sweepOrder.LongShort, TradingDirection.Short);
            Assert.AreEqual(sweepOrder.ReqPrice, 15000);

            Assert.AreEqual(shortSweepUnitTemplate_Accessor.CurState, SweepUnitTemplate.StateEnum._6_MonitorRequestedSweepOrders);

            Timer_Accessor mute_Accessor = new Timer_Accessor(new PrivateObject(shortSweepUnitTemplate_Accessor._mute));

            // 더이상 On이 풀리지 않는다.
            Assert.AreEqual(mute_Accessor.m_end > DateTime.Now.AddHours(1), true);

            // 여기서 많이 불러봐도 소용없다.
            Assert.AreEqual(sweeper.Run(), false);

            sweepOrder.Update(100 * CommonConst._1_000_000, 15000, false);

            Assert.AreEqual(sweeper.Run(), false);

            sweepOrder.Update(175 * CommonConst._1_000_000, 15000, true);

            Assert.AreEqual(sweeper.Run(), true);
        }
        void TestSweeper_BondArb_SN_Running(MonitorEnter_BondArb_Accessor me, Sweeper_BondArb sweeper)
        {
            Sweeper_BondArb_Accessor accessor = new Sweeper_BondArb_Accessor(new PrivateObject(sweeper));
            Assert.AreEqual(accessor._bDone, false);

            SweepUnitTemplate longSweepUnitTemplate = accessor._sweepUnitLong;
            SweepUnitTemplate_Accessor longSweepUnitTemplate_Accessor = new SweepUnitTemplate_Accessor(new PrivateObject(longSweepUnitTemplate));
            SweepUnitContext_Bond_Long longContext = longSweepUnitTemplate_Accessor.Context as SweepUnitContext_Bond_Long;
            SweepUnitContext_Bond_Long_Accessor longContext_Accessor = new SweepUnitContext_Bond_Long_Accessor(new PrivateObject(longContext));

            SweepUnitTemplate shortSweepUnitTemplate = accessor._sweepUnitShort;
            SweepUnitTemplate_Accessor shortSweepUnitTemplate_Accessor = new SweepUnitTemplate_Accessor(new PrivateObject(shortSweepUnitTemplate));
            SweepUnitContext_Bond_Short shortContext = shortSweepUnitTemplate_Accessor.Context as SweepUnitContext_Bond_Short;
            SweepUnitContext_Bond_Short_Accessor shortContext_Accessor = new SweepUnitContext_Bond_Short_Accessor(new PrivateObject(shortContext));

            // 1. 소액 25,000,000 체결
            POrder initLongOrder0 = longContext_Accessor._initOrders[0];
            // 주문번호 0
            initLongOrder0.OrderNumber = 0;
            initLongOrder0.Update(25 * CommonConst._1_000_000, 5000, false);
            Assert.AreEqual(initLongOrder0.ShortCutTargetOfContractCallBack.Contract_CallBack(initLongOrder0), true);

            Assert.AreEqual(shortSweepUnitTemplate.GetSignedPossibleContractCount(), 0);
            Assert.AreEqual(shortContext_Accessor.RealOrdersShort.Count, 0);

            initLongOrder0.Update(50 * CommonConst._1_000_000, 5000, true);
            Assert.AreEqual(initLongOrder0.ShortCutTargetOfContractCallBack.Contract_CallBack(initLongOrder0), true);

            Assert.AreEqual(shortSweepUnitTemplate.GetSignedPossibleContractCount(), 0);
            Assert.AreEqual(shortContext_Accessor.RealOrdersShort.Count, 0);

            POrder initLongOrder1 = longContext_Accessor._initOrders[1];
            initLongOrder1.OrderNumber = 0;
            initLongOrder1.Update(25 * CommonConst._1_000_000, 5000, false);
            Assert.AreEqual(initLongOrder1.ShortCutTargetOfContractCallBack.Contract_CallBack(initLongOrder1), true);

            Assert.AreEqual(shortSweepUnitTemplate.GetSignedPossibleContractCount(), 0);
            Assert.AreEqual(shortContext_Accessor.RealOrdersShort.Count, 0);

            initLongOrder1.Update(49999000, 5000, false);
            Assert.AreEqual(initLongOrder1.ShortCutTargetOfContractCallBack.Contract_CallBack(initLongOrder1), true);

            Assert.AreEqual(shortSweepUnitTemplate.GetSignedPossibleContractCount(), 0);
            Assert.AreEqual(shortContext_Accessor.RealOrdersShort.Count, 0);

            // 1억째 되었다
            initLongOrder1.Update(50 * CommonConst._1_000_000, 5000, true);
            Assert.AreEqual(initLongOrder1.ShortCutTargetOfContractCallBack.Contract_CallBack(initLongOrder1), true);

            Assert.AreEqual(shortSweepUnitTemplate.GetSignedPossibleContractCount(), (-1) * 100 * CommonConst._1_000_000);
            Assert.AreEqual(shortContext_Accessor.RealOrdersShort.Count, 1);

            POrder initLongOrder2 = longContext_Accessor._initOrders[2];
            initLongOrder2.OrderNumber = 0;
            initLongOrder2.Update(50 * CommonConst._1_000_000, 5000, true);
            Assert.AreEqual(initLongOrder2.ShortCutTargetOfContractCallBack.Contract_CallBack(initLongOrder2), true);

            Assert.AreEqual(shortSweepUnitTemplate.GetSignedPossibleContractCount(), (-1) * 100 * CommonConst._1_000_000);
            Assert.AreEqual(shortContext_Accessor.RealOrdersShort.Count, 1);

            POrder initLongOrder3 = longContext_Accessor._initOrders[3];
            initLongOrder3.OrderNumber = 0;
            initLongOrder3.Update(49999000, 5000, false);
            Assert.AreEqual(initLongOrder3.ShortCutTargetOfContractCallBack.Contract_CallBack(initLongOrder3), true);
            Assert.AreEqual(shortSweepUnitTemplate.GetSignedPossibleContractCount(), (-1) * 100 * CommonConst._1_000_000);
            Assert.AreEqual(shortContext_Accessor.RealOrdersShort.Count, 1);

            initLongOrder3.Update(50000000, 5000, true);
            Assert.AreEqual(initLongOrder3.ShortCutTargetOfContractCallBack.Contract_CallBack(initLongOrder3), true);
            Assert.AreEqual(shortSweepUnitTemplate.GetSignedPossibleContractCount(), (-1) * 200 * CommonConst._1_000_000);
            Assert.AreEqual(shortContext_Accessor.RealOrdersShort.Count, 2);

            // balance order
            POrder balanceOrder1 = shortContext_Accessor.RealOrdersShort[0];
            Assert.AreEqual(balanceOrder1.Code, _kHousingBondCode_Normal);
            Assert.AreEqual(balanceOrder1.LongShort, TradingDirection.Short);
            Assert.AreEqual(balanceOrder1.ReqCount, 100 * CommonConst._1_000_000);
            Assert.AreEqual(balanceOrder1.ReqPrice, 15000);

            POrder balanceOrder2 = shortContext_Accessor.RealOrdersShort[1];
            Assert.AreEqual(balanceOrder2.Code, _kHousingBondCode_Normal);
            Assert.AreEqual(balanceOrder2.LongShort, TradingDirection.Short);
            Assert.AreEqual(balanceOrder2.ReqCount, 100 * CommonConst._1_000_000);
            Assert.AreEqual(balanceOrder2.ReqPrice, 15000);

            // 2. 일반을 79,900,000만큼 체결시킨다.
            balanceOrder1.Update(79900 * CommonConst._1_000, 5000, false);
            Assert.AreEqual(balanceOrder1.ShortCutTargetOfContractCallBack.Contract_CallBack(balanceOrder1), true);

            // 4. Sweep 테스트를 진행한다.

            longSweepUnitTemplate_Accessor.CurState = SweepUnitTemplate.StateEnum._2_WaitUntilGotAllOrderNumber;
            shortSweepUnitTemplate_Accessor.CurState = SweepUnitTemplate.StateEnum._2_WaitUntilGotAllOrderNumber;

            balanceOrder1.OrderNumber = 0;
            balanceOrder2.OrderNumber = 0;

            POrder initLongOrder4 = longContext_Accessor._initOrders[4];
            POrder initLongOrder5 = longContext_Accessor._initOrders[5];

            initLongOrder4.OrderNumber = 0;
            initLongOrder5.OrderNumber = 0;

            Assert.AreEqual(sweeper.Run(), false);

            Assert.AreEqual(longSweepUnitTemplate_Accessor.CurState, SweepUnitTemplate.StateEnum._3_WaitUntilCancelAllOrders);
            Assert.AreEqual(shortSweepUnitTemplate_Accessor.CurState, SweepUnitTemplate.StateEnum._3_WaitUntilCancelAllOrders);

            initLongOrder4.Update(CommonConst._1_000, 5000, false);
            initLongOrder4.UpdateCancelMessage(initLongOrder4.ReqCount - CommonConst._1_000);
            initLongOrder5.UpdateCancelMessage(initLongOrder5.ReqCount);

            balanceOrder1.UpdateCancelMessage(balanceOrder1.ReqCount - balanceOrder1.ContractedCount);
            balanceOrder2.UpdateCancelMessage(balanceOrder2.ReqCount - balanceOrder2.ContractedCount);

            Assert.AreEqual(sweeper.Run(), false);

            Assert.AreEqual(longSweepUnitTemplate_Accessor.CurState, SweepUnitTemplate.StateEnum._4_WaitingRunSign);
            Assert.AreEqual(shortSweepUnitTemplate_Accessor.CurState, SweepUnitTemplate.StateEnum._4_WaitingRunSign);

            Assert.AreEqual(longContext_Accessor.CurSignedTargetCount, 300 * CommonConst._1_000_000);
            Assert.AreEqual(shortContext_Accessor.CurSignedTargetCount, (-1) * 300 * CommonConst._1_000_000);

            //Resume
            Assert.AreEqual(sweeper.Run(), false);

            Assert.AreEqual(longContext_Accessor.CurSignedTargetCount, 200 * CommonConst._1_000_000 + CommonConst._1_000);
            Assert.AreEqual(shortContext_Accessor.CurSignedTargetCount, (-1) * (200 * CommonConst._1_000_000 + CommonConst._1_000));

            Assert.AreEqual(longSweepUnitTemplate_Accessor.CurState, SweepUnitTemplate.StateEnum._7_Done);

            POrder sweepOrder1 = shortContext_Accessor.RealOrdersShort[2];
            POrder sweepOrder2 = shortContext_Accessor.RealOrdersShort[3];
            POrder sweepOrder3 = shortContext_Accessor.RealOrdersShort[4];

            //121,001,000
            Assert.AreEqual(sweepOrder1.ReqCount, 50 * CommonConst._1_000_000);
            Assert.AreEqual(sweepOrder2.ReqCount, 50 * CommonConst._1_000_000);
            Assert.AreEqual(sweepOrder3.ReqCount, 20101000);

            Assert.AreEqual(sweepOrder1.Code, _kHousingBondCode_Small);
            Assert.AreEqual(sweepOrder2.Code, _kHousingBondCode_Small);
            Assert.AreEqual(sweepOrder3.Code, _kHousingBondCode_Small);

            Assert.AreEqual(sweepOrder1.LongShort, TradingDirection.Short);
            Assert.AreEqual(sweepOrder2.LongShort, TradingDirection.Short);
            Assert.AreEqual(sweepOrder3.LongShort, TradingDirection.Short);

            Assert.AreEqual(sweepOrder1.ReqPrice, 15000);
            Assert.AreEqual(sweepOrder2.ReqPrice, 15000);
            Assert.AreEqual(sweepOrder3.ReqPrice, 15000);

            Assert.AreEqual(shortSweepUnitTemplate_Accessor.CurState, SweepUnitTemplate.StateEnum._6_MonitorRequestedSweepOrders);

            Timer_Accessor mute_Accessor = new Timer_Accessor(new PrivateObject(shortSweepUnitTemplate_Accessor._mute));

            // 더이상 On이 풀리지 않는다.
            Assert.AreEqual(mute_Accessor.m_end > DateTime.Now.AddHours(1), true);

            // 여기서 많이 불러봐도 소용없다.
            Assert.AreEqual(sweeper.Run(), false);

            sweepOrder1.Update(50000000, 15000, true);
            sweepOrder2.Update(50000000, 15000, true);

            Assert.AreEqual(sweeper.Run(), false);

            sweepOrder3.Update(20101000, 15000, true);

            Assert.AreEqual(sweeper.Run(), true);
        }
        void CreateOneSweeperAndSaveToUnittestFolder_NR()
        {
            // STR_Arb을 생성하여 MonitorEnter_BondArbTest를 생성한다.
            STR_Arb_Accessor arb = Unittest_BondArbUtil.CreateNewStrArbAccessor();
            StrategyNode node = arb._bondArbNode as StrategyNode;
            StrategyNode_Accessor nodeAccessor = new StrategyNode_Accessor(new PrivateObject(node));
            MonitorEnter_BondArb me = nodeAccessor._monitorEnter as MonitorEnter_BondArb;
            MonitorEnter_BondArb_Accessor meAccessor = new MonitorEnter_BondArb_Accessor(new PrivateObject(me));

            // 1. Create one sweeper
            BondPair doosanBondPair = null;
            RawMarketData rmdNormal = null;
            RawMarketData rmdRetail = null;

            SetCreditBondPairAndRmds(ref doosanBondPair, ref rmdNormal, ref rmdRetail);

            SetAsZeroRMD(ref rmdNormal);
            SetAsZeroRMD(ref rmdRetail);

            int ret = 0;

            // 5000에 일반을 사서 15000에 소매에 팔 수 있는 기회이다
            SetImmeLongPart(rmdNormal, 300 * CommonConst._1_000 * CommonConst._1_000, 5000);
            SetImmeShortPart(rmdNormal, 0, 0);
            SetImmeLongPart(rmdRetail, 0, 0);
            SetImmeShortPart(rmdRetail, 300 * CommonConst._1_000 * CommonConst._1_000, 15000);

            me.BeforeEnterSweeperChance();
            ret = meAccessor.CheckArbChance(doosanBondPair);

            Sweeper_BondArb sweeper = new Sweeper_BondArb(doosanBondPair, meAccessor._bondAccount);
            meAccessor._node.GetSweeperCollection().Add(sweeper);

            {
                Sweeper_BondArb_Accessor accessor = new Sweeper_BondArb_Accessor(new PrivateObject(sweeper));
                Assert.AreEqual(accessor._bDone, false);

                SweepUnitTemplate longSweepUnitTemplate = accessor._sweepUnitLong;
                SweepUnitTemplate_Accessor longSweepUnitTemplate_Accessor = new SweepUnitTemplate_Accessor(new PrivateObject(longSweepUnitTemplate));
                SweepUnitContext_Bond_Long longContext = longSweepUnitTemplate_Accessor.Context as SweepUnitContext_Bond_Long;
                SweepUnitContext_Bond_Long_Accessor longContext_Accessor = new SweepUnitContext_Bond_Long_Accessor(new PrivateObject(longContext));

                SweepUnitTemplate shortSweepUnitTemplate = accessor._sweepUnitShort;
                SweepUnitTemplate_Accessor shortSweepUnitTemplate_Accessor = new SweepUnitTemplate_Accessor(new PrivateObject(shortSweepUnitTemplate));
                SweepUnitContext_Bond_Short shortContext = shortSweepUnitTemplate_Accessor.Context as SweepUnitContext_Bond_Short;
                SweepUnitContext_Bond_Short_Accessor shortContext_Accessor = new SweepUnitContext_Bond_Short_Accessor(new PrivateObject(shortContext));

                POrder initLongOrder0 = longContext_Accessor._initOrders[0];
                // 주문번호 0
                initLongOrder0.OrderNumber = 0;
                initLongOrder0.Update(25 * CommonConst._1_000_000, 5000, false);
                Assert.AreEqual(initLongOrder0.ShortCutTargetOfContractCallBack.Contract_CallBack(initLongOrder0), true);

                Assert.AreEqual(shortSweepUnitTemplate.GetSignedPossibleContractCount(), (-1) * 25000000);
                Assert.AreEqual(shortContext_Accessor.RealOrdersShort.Count, 1);

                initLongOrder0.Update(50 * CommonConst._1_000_000, 5000, false);
                Assert.AreEqual(initLongOrder0.ShortCutTargetOfContractCallBack.Contract_CallBack(initLongOrder0), true);

                Assert.AreEqual(shortSweepUnitTemplate.GetSignedPossibleContractCount(), (-1) * 50000000);
                Assert.AreEqual(shortContext_Accessor.RealOrdersShort.Count, 2);

                // 2억 체결
                initLongOrder0.Update(200 * CommonConst._1_000_000, 5000, false);
                Assert.AreEqual(initLongOrder0.ShortCutTargetOfContractCallBack.Contract_CallBack(initLongOrder0), true);

                Assert.AreEqual(shortSweepUnitTemplate.GetSignedPossibleContractCount(), (-1) * 200 * CommonConst._1_000_000);
                Assert.AreEqual(shortContext_Accessor.RealOrdersShort.Count, 3);

                POrder balanceOrder0 = shortContext_Accessor.RealOrdersShort[0];
                POrder balanceOrder1 = shortContext_Accessor.RealOrdersShort[1];
                POrder balanceOrder2 = shortContext_Accessor.RealOrdersShort[2];

                balanceOrder0.OrderNumber = 0;
                balanceOrder1.OrderNumber = 0;
                balanceOrder2.OrderNumber = 0;

                // balance order
                Assert.AreEqual(balanceOrder0.Code, _kDoosanCode_Retail);
                Assert.AreEqual(balanceOrder0.LongShort, TradingDirection.Short);
                Assert.AreEqual(balanceOrder0.ReqCount, 25 * CommonConst._1_000_000);
                Assert.AreEqual(balanceOrder0.ReqPrice, 15000);

                // balance order 25,000,000 체결시킨다
                balanceOrder0.Update(25 * CommonConst._1_000_000, 15000, true);

                // Sweep
                longSweepUnitTemplate_Accessor.CurState = SweepUnitTemplate.StateEnum._2_WaitUntilGotAllOrderNumber;
                shortSweepUnitTemplate_Accessor.CurState = SweepUnitTemplate.StateEnum._2_WaitUntilGotAllOrderNumber;

                Assert.AreEqual(sweeper.Run(), false);

                Assert.AreEqual(longSweepUnitTemplate_Accessor.CurState, SweepUnitTemplate.StateEnum._3_WaitUntilCancelAllOrders);
                Assert.AreEqual(shortSweepUnitTemplate_Accessor.CurState, SweepUnitTemplate.StateEnum._3_WaitUntilCancelAllOrders);

                initLongOrder0.UpdateCancelMessage(initLongOrder0.ReqCount - initLongOrder0.ContractedCount);
                balanceOrder0.UpdateCancelMessage(balanceOrder0.ReqCount - balanceOrder0.ContractedCount);
                balanceOrder1.UpdateCancelMessage(balanceOrder1.ReqCount - balanceOrder1.ContractedCount);
                balanceOrder2.UpdateCancelMessage(balanceOrder2.ReqCount - balanceOrder2.ContractedCount);

                Assert.AreEqual(sweeper.Run(), false);

                Assert.AreEqual(longSweepUnitTemplate_Accessor.CurState, SweepUnitTemplate.StateEnum._4_WaitingRunSign);
                Assert.AreEqual(shortSweepUnitTemplate_Accessor.CurState, SweepUnitTemplate.StateEnum._4_WaitingRunSign);

                Assert.AreEqual(longContext_Accessor.CurSignedTargetCount, 300 * CommonConst._1_000_000);
                Assert.AreEqual(shortContext_Accessor.CurSignedTargetCount, (-1) * 300 * CommonConst._1_000_000);

                //Resume
                Assert.AreEqual(sweeper.Run(), false);

                Assert.AreEqual(longContext_Accessor.CurSignedTargetCount, 200 * CommonConst._1_000_000);
                Assert.AreEqual(shortContext_Accessor.CurSignedTargetCount, (-1) * 200 * CommonConst._1_000_000);

                Assert.AreEqual(longSweepUnitTemplate_Accessor.CurState, SweepUnitTemplate.StateEnum._7_Done);
            }

            // 2. save to unittest folder
            arb.SaveBondArbRemainPosition(Const.UNITTEST_BOND_ARB_REMAIN_POSITION_PATH);

            SetAsZeroAllCodes();
        }