コード例 #1
0
        public async Task IfPairSourceIsSpotAgvPrices_ShouldSendValidMessage()
        {
            //arrange
            var resultingOrderbook = new Orderbook("pair",
                                                   ImmutableArray.Create(new OrderbookPosition(1, 1000000)),
                                                   ImmutableArray.Create(new OrderbookPosition(2, 1000000)));

            var crossOrderbooks = ImmutableList.Create(
                new Orderbook("cross pair 1",
                              ImmutableArray.Create(new OrderbookPosition(11, 1000010)),
                              ImmutableArray.Create(new OrderbookPosition(12, 1000010))),
                new Orderbook("cross pair 2",
                              ImmutableArray.Create(new OrderbookPosition(21, 1000020)),
                              ImmutableArray.Create(new OrderbookPosition(22, 1000020))));

            _testSuit
            .Setup <IAssetPairSourceTypeService>(s => s.Get("pair") == AssetPairQuotesSourceTypeDomainEnum.SpotAgvPrices)
            .Setup <ISystem>(s => s.UtcNow == _now)
            .Setup <IReloadingManager <MarginTradingMarketMakerSettings> >(s =>
                                                                           s.CurrentValue == new MarginTradingMarketMakerSettings {
                MarketMakerId = "mm id"
            })
            .Setup <ICrossRatesService>(s => s.CalcDependentOrderbooks(resultingOrderbook.Equivalent()) == crossOrderbooks)
            .Setup <IPriceRoundingService>(m => m.Setup(s => s.GetRoundFunc(It.IsNotNull <string>())).Returns(p => p));

            //act
            await _testSuit.Sut.ProcessNewAvgSpotRate("pair", 1, 2);

            //assert
            var expectation = new List <OrderCommandsBatchMessage>
            {
                MakeOrderCommandsBatchMessage("pair", 0),
                MakeOrderCommandsBatchMessage("cross pair 1", 10),
                MakeOrderCommandsBatchMessage("cross pair 2", 20),
            };

            _sentMessages.Should().BeEquivalentTo(expectation);
        }