public void Snapshot() { var tracker = new TestTracker("name", 10); var snapshot = InitialSnapshot(); tracker.NewSnapshot(snapshot); Assert.Single(tracker.AskSides); Assert.Single(tracker.BidSides); Assert.Single(tracker.Timstamps); Assert.Empty(tracker.MisMatches); var expectedAsks = new OrderbookSide(new ExactFloatComparer()); var expectedBids = new OrderbookSide(new ExactFloatComparer()); foreach (LevelTuple tup in snapshot.Asks.Tuples) { expectedAsks.Add(new ExactFloat(tup.PriceLevel), new ExactFloat(tup.Volume)); } foreach (LevelTuple tup in snapshot.Bids.Tuples) { expectedBids.Add(new ExactFloat(tup.PriceLevel), new ExactFloat(tup.Volume)); } Assert.Equal(expectedAsks.Count, tracker.AskSides[0].Count); Assert.Equal(expectedBids.Count, tracker.BidSides[0].Count); foreach (KeyValuePair <ExactFloat, ExactFloat> pair in expectedAsks) { Assert.Equal(tracker.AskSides[0][pair.Key], pair.Value); } foreach (KeyValuePair <ExactFloat, ExactFloat> pair in expectedBids) { Assert.Equal(tracker.BidSides[0][pair.Key], pair.Value); } // max timestamp string maxA = snapshot.Asks.Tuples.Max(x => x.Timestamp) ?? throw new ArgumentNullException(nameof(snapshot)); string maxB = snapshot.Asks.Tuples.Max(x => x.Timestamp) ?? throw new ArgumentNullException(nameof(snapshot)); var em = string.Compare(maxA, maxB, StringComparison.Ordinal) >= 0 ? maxA : maxB; Assert.Equal(em, tracker.Timstamps[0]); Assert.Equal(em, tracker.Timstamps[0]); }