public void Prefix_WithExtendedClientId_ShouldFilterAsExpected(int?prefix, int expectedCount) { var source = GetSourceMock(); ICryptoOrders orders = new CryptoOrders(source, prefix); var updatedAll = new List <CryptoOrder>(); var updatedOurs = new List <CryptoOrder>(); orders.OrderChangedStream.Subscribe(x => updatedAll.Add(x)); orders.OurOrderChangedStream.Subscribe(x => updatedOurs.Add(x)); for (int i = 0; i < 10; i++) { var clientId = orders.GenerateClientId().ToString() + "::test_" + i; var side = i % 2 == 0 ? CryptoOrderSide.Bid : CryptoOrderSide.Ask; source.StreamOrder(GetOrderMock(clientId, "btcusd", side)); source.StreamOrder(GetOrderMock(null, "btcusd", side)); } var currentAll = orders.GetAllOrders(); var currentOurs = orders.GetOrders(); var currentActive = orders.GetActiveOrders(); Assert.Equal(expectedCount, updatedOurs.Count); Assert.Equal(expectedCount, currentOurs.Count); Assert.Equal(20, updatedAll.Count); Assert.Equal(20, currentAll.Count); Assert.Empty(currentActive); Assert.Equal(prefix * orders.ClientIdPrefixExponent, orders.ClientIdPrefix); Assert.Equal(prefix?.ToString() ?? string.Empty, orders.ClientIdPrefixString); }
public void TargetPair_ShouldFilterAsExpected(string pair, int expectedCount) { var source = GetSourceMock(); ICryptoOrders orders = new CryptoOrders(source, null, pair); var updatedAll = new List <CryptoOrder>(); var updatedOurs = new List <CryptoOrder>(); orders.OrderChangedStream.Subscribe(x => updatedAll.Add(x)); orders.OurOrderChangedStream.Subscribe(x => updatedOurs.Add(x)); var currentActive = orders.GetActiveOrders(); for (int i = 0; i < 10; i++) { var clientId1 = orders.GenerateClientId().ToString(); var clientId2 = orders.GenerateClientId().ToString(); var side = i % 2 == 0 ? CryptoOrderSide.Bid : CryptoOrderSide.Ask; source.StreamOrder(GetOrderMock(clientId1, "btcusd", side)); source.StreamOrder(GetOrderMock(clientId2, "neobtc", side)); } var currentAll = orders.GetAllOrders(); var currentOurs = orders.GetOrders(); Assert.Equal(expectedCount, updatedOurs.Count); Assert.Equal(expectedCount, currentOurs.Count); Assert.Equal(expectedCount, updatedAll.Count); Assert.Equal(expectedCount, currentAll.Count); Assert.Empty(currentActive); Assert.Equal(orders.TargetPairOriginal, pair); Assert.Equal(orders.TargetPair, CryptoPairsHelper.Clean(pair)); }