示例#1
0
        public void TestCopperForGoldOrderSell()
        {
            var askRepositoryMock = new Mock <IAskRepository>();

            askRepositoryMock.Setup(f => f.GetAsks()).Returns(GetAsksForCopperForGoldOrder());
            var commodityRepositoryMock = new Mock <ICommodityRepository>();

            commodityRepositoryMock.Setup(f => f.GetCommodities()).Returns(GetCommodities());
            Ask ask = new Ask();

            ask.AllowPartialFill     = true;
            ask.ApplyCommissionToBuy = true;
            ask.SellQuantity         = 5000;
            ask.CommodityBuyID       = copper;
            ask.CommoditySellID      = gold;
            ask.SellRatio            = 1294;
            ask.BuyRatio             = 3;
            ask.MaxLegDepth          = 4;
            var            askRepository = askRepositoryMock.Object;
            OrderProcessor proc          = new OrderProcessor(askRepository, commodityRepositoryMock.Object);

            proc.Start().Wait();
            Stopwatch watch = new Stopwatch();

            watch.Start();
            var order = proc.ExecuteAsk(ask);

            watch.Stop();
            TestContext.WriteLine(watch.ElapsedMilliseconds.ToString());
            Assert.AreNotEqual(0, order.Sum(o => o.OrderLegs.Where(ol => ol.CommodityBuyID == copper).Sum(ol => ol.BuyQuantity)));
        }