private void HandleUpdate(string symbol, bool full, CoinExSocketOrderBook data) { if (full) { SetInitialOrderBook(DateTime.UtcNow.Ticks, data.Bids, data.Asks); } else { UpdateOrderBook(DateTime.UtcNow.Ticks, data.Bids, data.Asks); } }
public void SubscribingToMarketDepthUpdates_Should_InvokeUpdateMethod() { // Arrange var sb = new StringBuilder(); var testWriter = new StringWriter(sb); var client = TestHelpers.PrepareSocketClient(() => Construct(new CoinExSocketClientOptions() { LogVerbosity = CryptoExchange.Net.Logging.LogVerbosity.Debug, LogWriters = new List <TextWriter> { testWriter } })); var expected = new CoinExSocketOrderBook() { Asks = new List <CoinExDepthEntry> { new CoinExDepthEntry() { Quantity = 0.1m, Price = 0.2m } }, Bids = new List <CoinExDepthEntry> { new CoinExDepthEntry() { Quantity = 0.1m, Price = 0.2m } } }; CoinExSocketOrderBook actual = null; var sendWait = TestHelpers.WaitForSend(client); var subTask = client.SubscribeToOrderBookUpdatesAsync("ETHBTC", 10, 1, (market, full, data) => { actual = data; }); if (!sendWait.Result) { Assert.Fail(sb.ToString()); } InvokeSubResponse(client); subTask.Wait(); // Act InvokeSubUpdate(client, "depth.update", true, expected, "ETHBTC"); // Assert Assert.IsTrue(subTask.Result.Success); Assert.IsTrue(actual != null); TestHelpers.PublicInstancePropertiesEqual(expected, actual); }