public void GetRatesTest_ChecksTheRatesForAllCurrencyPairsSubmittingDepthLevels_ChecksTheRatesReturnedToVerify()
        {
            MarketController marketController = (MarketController)_applicationContext["MarketController"];
            BBOMemoryImage   bboMemoryImage   = (BBOMemoryImage)_applicationContext["BBOMemoryImage"];

            DepthLevel xbtUsdBidLevel = new DepthLevel(new Price(491));
            DepthLevel ltcUsdBidLevel = new DepthLevel(new Price(492));
            DepthLevel btcUsdBidLevel = new DepthLevel(new Price(493));

            DepthLevel xbtUsdAskLevel = new DepthLevel(new Price(494));
            DepthLevel ltcUsdAskLevel = new DepthLevel(new Price(495));
            DepthLevel btcUsdAskLevel = new DepthLevel(new Price(496));

            bboMemoryImage.OnBBOArrived("XBT/USD", xbtUsdBidLevel, xbtUsdAskLevel);
            bboMemoryImage.OnBBOArrived("LTC/USD", ltcUsdBidLevel, ltcUsdAskLevel);
            bboMemoryImage.OnBBOArrived("BTC/USD", btcUsdBidLevel, btcUsdAskLevel);
            IHttpActionResult httpActionResult = marketController.GetAllRates();

            OkNegotiatedContentResult <RatesList> returnedOkRate = (OkNegotiatedContentResult <RatesList>)httpActionResult;
            RatesList ratesList = returnedOkRate.Content;

            Assert.AreEqual("XBT/USD", ratesList.ToList()[0].CurrencyPair);
            Assert.AreEqual(492.5, ratesList.ToList()[0].RateValue); // MidPoint of xbtUsdBidLevel = 491 & xbtUsdAskLevel = 494
            Assert.AreEqual("LTC/USD", ratesList.ToList()[1].CurrencyPair);
            Assert.AreEqual(493.5, ratesList.ToList()[1].RateValue); // MidPoint of ltcUsdBidLevel = 492 & ltcUsdAskLevel = 495
            Assert.AreEqual("BTC/USD", ratesList.ToList()[2].CurrencyPair);
            Assert.AreEqual(494.5, ratesList.ToList()[2].RateValue); // MidPoint of btcUsdBidLevel = 493 & btcUsdAskLevel = 496
        }
        public void GetRatesEndToEndTests_SubmitsOrdersAndChecksTheRatesForCurrencyPairs_VerifiesThroughTheReturnedRatesList()
        {
            // Get the instance through Spring configuration
            OrderController orderController = (OrderController)_applicationContext["OrderController"];

            orderController.Request = new HttpRequestMessage(HttpMethod.Post, "");
            orderController.Request.Headers.Add("Auth", "123456789");

            ManualResetEvent  manualResetEvent = new ManualResetEvent(false);
            IHttpActionResult orderHttpResult  = orderController.CreateOrder(new CreateOrderParam()
            {
                Pair   = "XBTUSD",
                Price  = 491,
                Volume = 100,
                Side   = "buy",
                Type   = "limit"
            });

            OkNegotiatedContentResult <NewOrderRepresentation> orderRepresentationContent = (OkNegotiatedContentResult <NewOrderRepresentation>)orderHttpResult;

            Assert.IsNotNull(orderRepresentationContent.Content);
            manualResetEvent.Reset();
            manualResetEvent.WaitOne(2000);
            orderController.CreateOrder(new CreateOrderParam()
            {
                Pair   = "BTCUSD",
                Price  = 493,
                Volume = 1000,
                Side   = "buy",
                Type   = "limit"
            });
            manualResetEvent.Reset();
            manualResetEvent.WaitOne(2000);
            orderController.CreateOrder(new CreateOrderParam()
            {
                Pair   = "XBTUSD",
                Price  = 494,
                Volume = 900,
                Side   = "sell",
                Type   = "limit"
            });
            manualResetEvent.Reset();
            manualResetEvent.WaitOne(2000);
            orderController.CreateOrder(new CreateOrderParam()
            {
                Pair   = "BTCUSD",
                Price  = 496,
                Volume = 700,
                Side   = "sell",
                Type   = "limit"
            });
            manualResetEvent.Reset();
            manualResetEvent.WaitOne(2000);
            MarketController marketController = (MarketController)_applicationContext["MarketController"];

            IHttpActionResult httpActionResult = marketController.GetAllRates();
            OkNegotiatedContentResult <RatesList> okResponse = (OkNegotiatedContentResult <RatesList>)httpActionResult;

            RatesList ratesList = okResponse.Content;

            Assert.AreEqual("XBTUSD", ratesList.ToList()[0].CurrencyPair);
            Assert.AreEqual(492.5, ratesList.ToList()[0].RateValue); // MidPoint of xbtUsdBidLevel = 491 & xbtUsdAskLevel = 494
            Assert.AreEqual("BTCUSD", ratesList.ToList()[1].CurrencyPair);
            Assert.AreEqual(494.5, ratesList.ToList()[1].RateValue); // MidPoint of btcUsdBidLevel = 493 & btcUsdAskLevel = 496
        }