private void VerifyDepthBeforeAndAfterReplay(DepthTupleRepresentation beforeReplay, DepthTupleRepresentation afterReplay) { for (int i = 0; i < 5; i++) { Assert.AreEqual(beforeReplay.BidDepth[i].Volume, afterReplay.BidDepth[i].Volume); Assert.AreEqual(beforeReplay.BidDepth[i].Price, afterReplay.BidDepth[i].Price); Assert.AreEqual(beforeReplay.BidDepth[i].OrderCount, afterReplay.BidDepth[i].OrderCount); Assert.AreEqual(beforeReplay.AskDepth[i].Volume, afterReplay.AskDepth[i].Volume); Assert.AreEqual(beforeReplay.AskDepth[i].Price, afterReplay.AskDepth[i].Price); Assert.AreEqual(beforeReplay.AskDepth[i].OrderCount, afterReplay.AskDepth[i].OrderCount); } }
private void VerifyDepthWhenOrdersPublishedAfterReplayForScenario1(DepthTupleRepresentation representation) { //0 index Assert.AreEqual(representation.BidDepth[0].Price, 406); Assert.AreEqual(representation.BidDepth[0].Volume, 201); Assert.AreEqual(representation.BidDepth[0].OrderCount, 2); Assert.AreEqual(representation.AskDepth[0].Price, 407); Assert.AreEqual(representation.AskDepth[0].Volume, 202); Assert.AreEqual(representation.AskDepth[0].OrderCount, 2); //1 index Assert.AreEqual(representation.BidDepth[1].Price, 405); Assert.AreEqual(representation.BidDepth[1].Volume, 106); Assert.AreEqual(representation.BidDepth[1].OrderCount, 2); Assert.AreEqual(representation.AskDepth[1].Price, 409); Assert.AreEqual(representation.AskDepth[1].Volume, 205); Assert.AreEqual(representation.AskDepth[1].OrderCount, 2); //2 index Assert.AreEqual(representation.BidDepth[2].Price, 404); Assert.AreEqual(representation.BidDepth[2].Volume, 104); Assert.AreEqual(representation.BidDepth[2].OrderCount, 1); Assert.AreEqual(representation.AskDepth[2].Price, 410); Assert.AreEqual(representation.AskDepth[2].Volume, 100); Assert.AreEqual(representation.AskDepth[2].OrderCount, 1); //3 index Assert.AreEqual(representation.BidDepth[3].Price, 403); Assert.AreEqual(representation.BidDepth[3].Volume, 103); Assert.AreEqual(representation.BidDepth[3].OrderCount, 1); Assert.AreEqual(representation.AskDepth[3].Price, 411); Assert.AreEqual(representation.AskDepth[3].Volume, 105); Assert.AreEqual(representation.AskDepth[3].OrderCount, 1); //4 index Assert.AreEqual(representation.BidDepth[4].Price, 402); Assert.AreEqual(representation.BidDepth[4].Volume, 102); Assert.AreEqual(representation.BidDepth[4].OrderCount, 1); Assert.AreEqual(representation.AskDepth[4].Price, 412); Assert.AreEqual(representation.AskDepth[4].Volume, 106); Assert.AreEqual(representation.AskDepth[4].OrderCount, 1); }
public void GetDepthFromControllerTest_TestsTheLinkBetweenMarketControllerAndMArketQueryService_ChecksTheOutputToBeAsExpected() { // Get the context //IApplicationContext applicationContext = ContextRegistry.GetContext(); // Get the instance through Spring configuration MarketController marketController = (MarketController)_applicationContext["MarketController"]; Depth depth = new Depth("XBTUSD", 3); depth.AddOrder(new Price(491), new Volume(100), OrderSide.Buy); depth.AddOrder(new Price(492), new Volume(100), OrderSide.Buy); depth.AddOrder(new Price(492), new Volume(200), OrderSide.Buy); depth.AddOrder(new Price(490), new Volume(100), OrderSide.Sell); depth.AddOrder(new Price(490), new Volume(100), OrderSide.Sell); depth.AddOrder(new Price(490), new Volume(200), OrderSide.Sell); DepthMemoryImage depthMemoryImage = (DepthMemoryImage)_applicationContext["DepthMemoryImage"]; depthMemoryImage.OnDepthArrived(depth); IHttpActionResult httpActionResult = marketController.GetDepth("XBTUSD"); OkNegotiatedContentResult <object> result = (OkNegotiatedContentResult <object>)httpActionResult; DepthTupleRepresentation returnedDepths = result.Content as DepthTupleRepresentation; Assert.IsNotNull(returnedDepths); // Bid Depth First Element represented as Item1 Assert.AreEqual(300, returnedDepths.BidDepth.ToList()[0].Volume); // Aggregated Volume Assert.AreEqual(492, returnedDepths.BidDepth.ToList()[0].Price); // Price Assert.AreEqual(2, returnedDepths.BidDepth.ToList()[0].OrderCount); // OrderCount // Ask Depth First Element represented as Item2 Assert.AreEqual(400, returnedDepths.AskDepth.ToList()[0].Volume); // Aggregated Volume Assert.AreEqual(490, returnedDepths.AskDepth.ToList()[0].Price); // Price Assert.AreEqual(3, returnedDepths.AskDepth.ToList()[0].OrderCount); // OrderCount }
public void ReplayOrderBook_IfScenario2IsExecuted_VerifyTheWholeSystemState() { _applicationContext = ContextRegistry.GetContext(); Scenario2(); MarketController marketController = (MarketController)_applicationContext["MarketController"]; IHttpActionResult marketDataHttpResult = marketController.GetOrderBook("XBTUSD"); OkNegotiatedContentResult <object> okResponseMessage = (OkNegotiatedContentResult <object>)marketDataHttpResult; OrderBookRepresentation representation = okResponseMessage.Content as OrderBookRepresentation; Tuple <OrderRepresentationList, OrderRepresentationList> orderBooks = new Tuple <OrderRepresentationList, OrderRepresentationList>(representation.Bids, representation.Asks); marketDataHttpResult = marketController.GetDepth("XBTUSD"); OkNegotiatedContentResult <object> okResponseMessageDepth = (OkNegotiatedContentResult <object>)marketDataHttpResult; DepthTupleRepresentation beforeReplayDepth = okResponseMessageDepth.Content as DepthTupleRepresentation; IOrderRepository orderRepository = (IOrderRepository)_applicationContext["OrderRepository"]; List <OrderReadModel> before = orderRepository.GetAllOrderOfTrader("5555"); before = before.Concat(orderRepository.GetAllOrderOfTrader("4444")).ToList(); ITradeRepository tradeRepository = (ITradeRepository)_applicationContext["TradeRepository"]; IList <TradeReadModel> beforeReplayTrades = tradeRepository.GetAll(); IList <object> beforeReplayEvents = outputEventStore.GetAllEvents(); marketDataHttpResult = marketController.GetBbo("XBTUSD"); OkNegotiatedContentResult <BBORepresentation> okResponseMessageBboBefore = (OkNegotiatedContentResult <BBORepresentation>)marketDataHttpResult; //down the exchange, make new exchange and reply CrashAndInitializeAgainWithSnapshot(); marketController = (MarketController)_applicationContext["MarketController"]; marketDataHttpResult = marketController.GetOrderBook("XBTUSD"); okResponseMessage = (OkNegotiatedContentResult <object>)marketDataHttpResult; representation = okResponseMessage.Content as OrderBookRepresentation; Tuple <OrderRepresentationList, OrderRepresentationList> orderBook1 = new Tuple <OrderRepresentationList, OrderRepresentationList>(representation.Bids, representation.Asks); //verify orderbook state VerifyOrderBookStateAfterReplay(orderBooks, orderBook1); List <OrderReadModel> after = orderRepository.GetAllOrderOfTrader("5555"); after = after.Concat(orderRepository.GetAllOrderOfTrader("4444")).ToList(); //verify order table in database VerifyDatabaseStateAfterReplay(before, after); IList <TradeReadModel> afterReplayTrades = tradeRepository.GetAll(); //verify trades table in database VerifyDatabaseStateAfterReplay(beforeReplayTrades, afterReplayTrades); IList <object> afterReplayEvents = outputEventStore.GetAllEvents(); //verify event store state VerifyEventStoreStateAfterReplay(beforeReplayEvents, afterReplayEvents); marketDataHttpResult = marketController.GetDepth("XBTUSD"); okResponseMessageDepth = (OkNegotiatedContentResult <object>)marketDataHttpResult; DepthTupleRepresentation afterReplayDepth = okResponseMessageDepth.Content as DepthTupleRepresentation; VerifyDepthBeforeAndAfterReplay(beforeReplayDepth, afterReplayDepth); marketDataHttpResult = marketController.GetBbo("XBTUSD"); OkNegotiatedContentResult <BBORepresentation> okResponseMessageBboAfter = (OkNegotiatedContentResult <BBORepresentation>)marketDataHttpResult; VerifyBboAfterReplay(okResponseMessageBboBefore.Content, okResponseMessageBboAfter.Content); }
public void SubmitOrdersAndGetDepthTest_SubmitsAnOrderAndGetsTheDepthAsTheResult_VerifiesIfDepthIsAsExpected() { // 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 = "BTCUSD", Price = 491, Volume = 100, Side = "buy", Type = "limit" }); OkNegotiatedContentResult <NewOrderRepresentation> orderRepresentationContent = (OkNegotiatedContentResult <NewOrderRepresentation>)orderHttpResult; Assert.IsNotNull(orderRepresentationContent.Content); manualResetEvent.Reset(); manualResetEvent.WaitOne(1000); orderController.CreateOrder(new CreateOrderParam() { Pair = "BTCUSD", Price = 491, Volume = 300, Side = "buy", Type = "limit" }); manualResetEvent.Reset(); manualResetEvent.WaitOne(1000); orderController.CreateOrder(new CreateOrderParam() { Pair = "BTCUSD", Price = 493, Volume = 1000, Side = "buy", Type = "limit" }); orderController.CreateOrder(new CreateOrderParam() { Pair = "BTCUSD", Price = 498, Volume = 900, Side = "sell", Type = "limit" }); manualResetEvent.Reset(); manualResetEvent.WaitOne(1000); orderController.CreateOrder(new CreateOrderParam() { Pair = "BTCUSD", Price = 498, Volume = 800, Side = "sell", Type = "limit" }); manualResetEvent.Reset(); manualResetEvent.WaitOne(1000); orderController.CreateOrder(new CreateOrderParam() { Pair = "BTCUSD", Price = 497, Volume = 700, Side = "sell", Type = "limit" }); manualResetEvent.Reset(); manualResetEvent.WaitOne(2000); MarketController marketController = (MarketController)_applicationContext["MarketController"]; IHttpActionResult marketDataHttpResult = marketController.GetDepth("BTCUSD"); OkNegotiatedContentResult <object> okResponseMessage = (OkNegotiatedContentResult <object>)marketDataHttpResult; DepthTupleRepresentation returnedDepth = okResponseMessage.Content as DepthTupleRepresentation; Assert.AreEqual(1000, returnedDepth.BidDepth[0].Volume); // Volume of the first Bid DepthLevel Assert.AreEqual(493, returnedDepth.BidDepth[0].Price); // Price of the first Bid DepthLevel Assert.AreEqual(400, returnedDepth.BidDepth[1].Volume); // Volume of the second Bid DepthLevel Assert.AreEqual(491, returnedDepth.BidDepth[1].Price); // Price of the second Bid DepthLevel Assert.AreEqual(700, returnedDepth.AskDepth[0].Volume); // Volume of the first Ask DepthLevel Assert.AreEqual(497, returnedDepth.AskDepth[0].Price); // Price of the first Ask DepthLevel Assert.AreEqual(1700, returnedDepth.AskDepth[1].Volume); // Volume of the second Ask DepthLevel Assert.AreEqual(498, returnedDepth.AskDepth[1].Price); // Price of the second Ask DepthLevel }
public void Scenario3Test_TestsScenario3AndItsOutcome_VerifiesThroughMarketDataOrderAndTradesResults() { // Get the context IApplicationContext applicationContext = ContextRegistry.GetContext(); // Get the instance through Spring configuration OrderController orderController = (OrderController)applicationContext["OrderController"]; TradeController tradeController = (TradeController)applicationContext["TradeController"]; MarketController marketController = (MarketController)applicationContext["MarketController"]; orderController.Request = new HttpRequestMessage(HttpMethod.Post, ""); orderController.Request.Headers.Add("Auth", "123456789"); tradeController.Request = new HttpRequestMessage(HttpMethod.Post, ""); tradeController.Request.Headers.Add("Auth", "123456789"); marketController.Request = new HttpRequestMessage(HttpMethod.Post, ""); marketController.Request.Headers.Add("Auth", "123456789"); Scenario3OrderCreation(orderController); // ------------------------------- Order Book ------------------------------ IHttpActionResult orderBookResponse = marketController.GetOrderBook("BTCLTC"); OkNegotiatedContentResult <object> okOrderBookResponse = (OkNegotiatedContentResult <object>)orderBookResponse; OrderBookRepresentation representation = okOrderBookResponse.Content as OrderBookRepresentation; Tuple <OrderRepresentationList, OrderRepresentationList> orderBook = new Tuple <OrderRepresentationList, OrderRepresentationList>(representation.Bids, representation.Asks); // Item1 = Bid Book, Item1[i].Item1 = Volume of 'i' Bid, Item1[i].Item2 = Price of 'i' Bid Assert.AreEqual(0, orderBook.Item1.Count()); // Item2 = Bid Book, Item2[i].Item1 = Volume of Ask at index 'i', Item2[i].Item2 = Price of Bid at index 'i' Assert.AreEqual(0, orderBook.Item2.Count()); // ------------------------------------------------------------------------ // --------------------------------- Depth --------------------------------- IHttpActionResult depthResponse = marketController.GetDepth("BTCLTC"); OkNegotiatedContentResult <object> okDepth = (OkNegotiatedContentResult <object>)depthResponse; DepthTupleRepresentation depth = okDepth.Content as DepthTupleRepresentation; // Item1 = Bid Book, Item1.Item1 = Aggregated Volume, Item1.Item2 = Price, Item1.Item3 = Number of Orders Assert.IsNull(depth.BidDepth[0]); Assert.IsNull(depth.BidDepth[1]); Assert.IsNull(depth.BidDepth[2]); Assert.IsNull(depth.BidDepth[3]); Assert.IsNull(depth.BidDepth[4]); // Item2 = Bid Book, Item2.Item1 = Aggregated Volume, Item2.Item2 = Price, Item2.Item3 = Number of Orders Assert.IsNull(depth.AskDepth[0]); Assert.IsNull(depth.AskDepth[1]); Assert.IsNull(depth.AskDepth[2]); Assert.IsNull(depth.AskDepth[3]); Assert.IsNull(depth.AskDepth[4]); // ----------------------------------------------------------------------- //------------------------- Open Orders ---------------------------------- IHttpActionResult openOrdersResponse = GetOpenOrders(orderController); OkNegotiatedContentResult <List <OrderReadModel> > okOpenOrdersResponse = (OkNegotiatedContentResult <List <OrderReadModel> >)openOrdersResponse; List <OrderReadModel> openOrders = okOpenOrdersResponse.Content; Assert.AreEqual(0, openOrders.Count); //--------------------------------------------------------------------- //-------------------------- Closed Orders ---------------------------- IHttpActionResult closedOrdersResponse = GetClosedOrders(orderController); OkNegotiatedContentResult <List <OrderReadModel> > okClosedOrdersResponse = (OkNegotiatedContentResult <List <OrderReadModel> >)closedOrdersResponse; List <OrderReadModel> closedOrders = okClosedOrdersResponse.Content; // Order List comes in descending order, so asserts are placed that way too Assert.AreEqual(252, closedOrders[8].Price); Assert.AreEqual(5, closedOrders[8].Volume); Assert.AreEqual(0, closedOrders[8].VolumeExecuted); Assert.AreEqual(5, closedOrders[8].OpenQuantity); Assert.AreEqual("Limit", closedOrders[8].Type); Assert.AreEqual("Sell", closedOrders[8].Side); Assert.AreEqual("Cancelled", closedOrders[8].Status); Assert.AreEqual(245, closedOrders[7].Price); Assert.AreEqual(8, closedOrders[7].Volume); Assert.AreEqual(0, closedOrders[7].VolumeExecuted); Assert.AreEqual(8, closedOrders[7].OpenQuantity); Assert.AreEqual("Limit", closedOrders[7].Type); Assert.AreEqual("Buy", closedOrders[7].Side); Assert.AreEqual("Cancelled", closedOrders[7].Status); Assert.AreEqual(250, closedOrders[6].Price); Assert.AreEqual(7, closedOrders[6].Volume); Assert.AreEqual(7, closedOrders[6].VolumeExecuted); Assert.AreEqual(0, closedOrders[6].OpenQuantity); Assert.AreEqual("Limit", closedOrders[6].Type); Assert.AreEqual("Buy", closedOrders[6].Side); Assert.AreEqual("Complete", closedOrders[6].Status); Assert.AreEqual(250, closedOrders[5].Price); Assert.AreEqual(3, closedOrders[5].Volume); Assert.AreEqual(2, closedOrders[5].VolumeExecuted); Assert.AreEqual(1, closedOrders[5].OpenQuantity); Assert.AreEqual("Limit", closedOrders[5].Type); Assert.AreEqual("Buy", closedOrders[5].Side); Assert.AreEqual("Cancelled", closedOrders[5].Status); Assert.AreEqual(253, closedOrders[4].Price); Assert.AreEqual(5, closedOrders[4].Volume); Assert.AreEqual(0, closedOrders[4].VolumeExecuted); Assert.AreEqual(5, closedOrders[4].OpenQuantity); Assert.AreEqual("Limit", closedOrders[4].Type); Assert.AreEqual("Sell", closedOrders[4].Side); Assert.AreEqual("Cancelled", closedOrders[4].Status); Assert.AreEqual(240, closedOrders[3].Price); Assert.AreEqual(8, closedOrders[3].Volume); Assert.AreEqual(0, closedOrders[3].VolumeExecuted); Assert.AreEqual(8, closedOrders[3].OpenQuantity); Assert.AreEqual("Limit", closedOrders[3].Type); Assert.AreEqual("Buy", closedOrders[3].Side); Assert.AreEqual("Cancelled", closedOrders[3].Status); Assert.AreEqual(245, closedOrders[2].Price); Assert.AreEqual(7, closedOrders[2].Volume); Assert.AreEqual(0, closedOrders[2].VolumeExecuted); Assert.AreEqual(7, closedOrders[2].OpenQuantity); Assert.AreEqual("Limit", closedOrders[2].Type); Assert.AreEqual("Buy", closedOrders[2].Side); Assert.AreEqual("Cancelled", closedOrders[2].Status); Assert.AreEqual(247, closedOrders[1].Price); Assert.AreEqual(3, closedOrders[1].Volume); Assert.AreEqual(0, closedOrders[1].VolumeExecuted); Assert.AreEqual(3, closedOrders[1].OpenQuantity); Assert.AreEqual("Limit", closedOrders[1].Type); Assert.AreEqual("Buy", closedOrders[1].Side); Assert.AreEqual("Cancelled", closedOrders[1].Status); Assert.AreEqual(0, closedOrders[0].Price); Assert.AreEqual(9, closedOrders[0].Volume); Assert.AreEqual(9, closedOrders[0].VolumeExecuted); Assert.AreEqual(0, closedOrders[0].OpenQuantity); Assert.AreEqual("Market", closedOrders[0].Type); Assert.AreEqual("Sell", closedOrders[0].Side); Assert.AreEqual("Complete", closedOrders[0].Status); //------------------------------------------------------------------------ //------------------- Trades ------------------------- IHttpActionResult tradesResponse = GetTrades(tradeController); OkNegotiatedContentResult <object> okTradeResponse = (OkNegotiatedContentResult <object>)tradesResponse; IList <object> tradesintermediateList = (IList <object>)okTradeResponse.Content; IList <object[]> trades = new List <object[]>(); for (int i = 0; i < tradesintermediateList.Count; i++) { object[] objects = tradesintermediateList[i] as object[]; trades.Add(objects); } // These trades execute simultaneously, so when queried from the database and sorted as per the time when // they were saved in the database, they can be queried out of the order as we expected because they have the // same time. So we check if one trade came before the other and place assertions for it then for the other and // vice versa if ((decimal)trades[1][3] == 7) { Assert.AreEqual(250, trades[1][2]); // Price Assert.AreEqual(7, trades[1][3]); // Volume Assert.AreEqual("BTCLTC", trades[1][4]); // CurrencyPair } else if ((decimal)trades[1][3] == 2) { Assert.AreEqual(250, trades[1][2]); Assert.AreEqual(2, trades[1][3]); Assert.AreEqual("BTCLTC", trades[1][4]); } else { throw new Exception("No assertions could be made on expected trade"); } if ((decimal)trades[0][3] == 7) { Assert.AreEqual(250, trades[0][2]); // Price Assert.AreEqual(7, trades[0][3]); // Volume Assert.AreEqual("BTCLTC", trades[0][4]); // CurrencyPair } else if ((decimal)trades[0][3] == 2) { Assert.AreEqual(250, trades[0][2]); // Price Assert.AreEqual(2, trades[0][3]); // Volume Assert.AreEqual("BTCLTC", trades[0][4]); // CurrencyPair } else { throw new Exception("No assertions could be made on expected trade"); } //----------------------------------------------------------------------- }
public void Scenario1Test_TestsScenario1AndItsOutcome_VerifiesThroughMarketDataOrderAndTradesResults() { // Get the context IApplicationContext applicationContext = ContextRegistry.GetContext(); // Get the instance through Spring configuration OrderController orderController = (OrderController)applicationContext["OrderController"]; TradeController tradeController = (TradeController)applicationContext["TradeController"]; MarketController marketController = (MarketController)applicationContext["MarketController"]; orderController.Request = new HttpRequestMessage(HttpMethod.Post, ""); orderController.Request.Headers.Add("Auth", "123456789"); tradeController.Request = new HttpRequestMessage(HttpMethod.Post, ""); tradeController.Request.Headers.Add("Auth", "123456789"); marketController.Request = new HttpRequestMessage(HttpMethod.Post, ""); marketController.Request.Headers.Add("Auth", "123456789"); Scenario1OrderCreation(orderController); // ------------------------------- Order Book ------------------------------ IHttpActionResult orderBookResponse = marketController.GetOrderBook("BTCLTC"); OkNegotiatedContentResult <object> okOrderBookResponse = (OkNegotiatedContentResult <object>)orderBookResponse; OrderBookRepresentation representation = okOrderBookResponse.Content as OrderBookRepresentation; Tuple <OrderRepresentationList, OrderRepresentationList> orderBook = new Tuple <OrderRepresentationList, OrderRepresentationList>(representation.Bids, representation.Asks); // Item1 = Bid Book, Item1[i].Item1 = Volume of 'i' Bid, Item1[i].Item2 = Price of 'i' Bid Assert.AreEqual(5, orderBook.Item1.ToList()[0].Volume); Assert.AreEqual(250, orderBook.Item1.ToList()[0].Price); Assert.AreEqual(2, orderBook.Item1.ToList()[1].Volume); Assert.AreEqual(250, orderBook.Item1.ToList()[1].Price); // Item2 = Ask Book, Item2[i].Item1 = Volume of Ask at index 'i', Item2[i].Item2 = Price of Ask at index 'i' Assert.AreEqual(0, orderBook.Item2.Count()); // ------------------------------- Order Book ------------------------------ IHttpActionResult depthResponse = marketController.GetDepth("BTCLTC"); OkNegotiatedContentResult <object> okDepth = (OkNegotiatedContentResult <object>)depthResponse; DepthTupleRepresentation depth = okDepth.Content as DepthTupleRepresentation; // Item1 = Bid Book, Item1.Item1 = Aggregated Volume, Item1.Item2 = Price, Item1.Item3 = Number of Orders Assert.AreEqual(7, depth.BidDepth[0].Volume); Assert.AreEqual(250, depth.BidDepth[0].Price); Assert.AreEqual(2, depth.BidDepth[0].OrderCount); Assert.IsNull(depth.BidDepth[1]); Assert.IsNull(depth.BidDepth[2]); Assert.IsNull(depth.BidDepth[3]); Assert.IsNull(depth.BidDepth[4]); // Item2 = Ask Book, Item2.Item1 = Aggregated Volume, Item2.Item2 = Price, Item2.Item3 = Number of Orders Assert.IsNull(depth.AskDepth[0]); Assert.IsNull(depth.AskDepth[1]); Assert.IsNull(depth.AskDepth[2]); Assert.IsNull(depth.AskDepth[3]); Assert.IsNull(depth.AskDepth[4]); //------------------- Open Orders ------------------------- IHttpActionResult openOrdersResponse = GetOpenOrders(orderController); OkNegotiatedContentResult <List <OrderReadModel> > okOpenOrdersResponse = (OkNegotiatedContentResult <List <OrderReadModel> >)openOrdersResponse; List <OrderReadModel> openOrders = okOpenOrdersResponse.Content; Assert.AreEqual(2, openOrders.Count); // First Open Order Assert.AreEqual(250, openOrders[1].Price); Assert.AreEqual(10, openOrders[1].Volume); Assert.AreEqual(5, openOrders[1].VolumeExecuted); Assert.AreEqual(5, openOrders[1].OpenQuantity); Assert.AreEqual("Limit", openOrders[1].Type); Assert.AreEqual("Buy", openOrders[1].Side); Assert.AreEqual("PartiallyFilled", openOrders[1].Status); // Second Open Order Assert.AreEqual(250, openOrders[0].Price); Assert.AreEqual(2, openOrders[0].Volume); Assert.AreEqual(0, openOrders[0].VolumeExecuted); Assert.AreEqual(2, openOrders[0].OpenQuantity); Assert.AreEqual("Limit", openOrders[0].Type); Assert.AreEqual("Buy", openOrders[0].Side); Assert.AreEqual("Accepted", openOrders[0].Status); //------------------- Open Orders ------------------------- //------------------- Closed Orders ------------------------- IHttpActionResult closedOrdersResponse = GetClosedOrders(orderController); OkNegotiatedContentResult <List <OrderReadModel> > okClosedOrdersResponse = (OkNegotiatedContentResult <List <OrderReadModel> >)closedOrdersResponse; List <OrderReadModel> closedOrders = okClosedOrdersResponse.Content; Assert.AreEqual(252, closedOrders[3].Price); Assert.AreEqual(5, closedOrders[3].Volume); Assert.AreEqual(5, closedOrders[3].VolumeExecuted); Assert.AreEqual(0, closedOrders[3].OpenQuantity); Assert.AreEqual("Limit", closedOrders[3].Type); Assert.AreEqual("Sell", closedOrders[3].Side); Assert.AreEqual("Complete", closedOrders[3].Status); Assert.AreEqual(0, closedOrders[2].Price); Assert.AreEqual(3, closedOrders[2].Volume); Assert.AreEqual(3, closedOrders[2].VolumeExecuted); Assert.AreEqual(0, closedOrders[2].OpenQuantity); Assert.AreEqual("Market", closedOrders[2].Type); Assert.AreEqual("Buy", closedOrders[2].Side); Assert.AreEqual("Complete", closedOrders[2].Status); Assert.AreEqual(253, closedOrders[1].Price); Assert.AreEqual(2, closedOrders[1].Volume); Assert.AreEqual(2, closedOrders[1].VolumeExecuted); Assert.AreEqual(0, closedOrders[1].OpenQuantity); Assert.AreEqual("Limit", closedOrders[1].Type); Assert.AreEqual("Buy", closedOrders[1].Side); Assert.AreEqual("Complete", closedOrders[1].Status); Assert.AreEqual(0, closedOrders[0].Price); Assert.AreEqual(5, closedOrders[0].Volume); Assert.AreEqual(5, closedOrders[0].VolumeExecuted); Assert.AreEqual(0, closedOrders[0].OpenQuantity); Assert.AreEqual("Market", closedOrders[0].Type); Assert.AreEqual("Sell", closedOrders[0].Side); Assert.AreEqual("Complete", closedOrders[0].Status); //------------------- Closed Orders ------------------------- //------------------- Trades ------------------------- IHttpActionResult tradesResponse = GetTrades(tradeController); OkNegotiatedContentResult <object> okTradeResponse = (OkNegotiatedContentResult <object>)tradesResponse; IList <object> tradesintermediateList = (IList <object>)okTradeResponse.Content; IList <object[]> trades = new List <object[]>(); for (int i = 0; i < tradesintermediateList.Count; i++) { object[] objects = tradesintermediateList[i] as object[]; trades.Add(objects); } // This call return list of object, so we have to explicitly check values within elements Assert.AreEqual(252, trades[2][2]); // Price Assert.AreEqual(3, trades[2][3]); // Volume Assert.AreEqual("BTCLTC", trades[2][4]); Assert.AreEqual(252, trades[1][2]); Assert.AreEqual(2, trades[1][3]); Assert.AreEqual("BTCLTC", trades[0][4]); Assert.AreEqual(250, trades[0][2]); Assert.AreEqual(5, trades[0][3]); Assert.AreEqual("BTCLTC", trades[0][4]); //------------------- Trades ------------------------- }