Пример #1
0
        public void CancelOrders_ShouldReturnBinanceOrder()
        {
            //Arrange
            _httpMessageHandlerMock
            .Protected()
            .Setup <Task <HttpResponseMessage> >("SendAsync",
                                                 ItExpr.Is <HttpRequestMessage>(x => x.RequestUri.AbsoluteUri.Contains("/api/v1/time")),
                                                 ItExpr.IsAny <CancellationToken>())
            .Returns(Task.FromResult(new HttpResponseMessage(HttpStatusCode.OK)
            {
                StatusCode = HttpStatusCode.OK,
                Content    = new StringContent(
                    @"{""serverTime"":1592395836992}")
            }))
            .Verifiable();
            _httpMessageHandlerMock
            .Protected()
            .Setup <Task <HttpResponseMessage> >("SendAsync",
                                                 ItExpr.Is <HttpRequestMessage>(x => x.RequestUri.AbsoluteUri.Contains("/api/v3/openOrders")),
                                                 ItExpr.IsAny <CancellationToken>())
            .Returns(Task.FromResult(new HttpResponseMessage(HttpStatusCode.OK)
            {
                StatusCode = HttpStatusCode.OK,
                Content    = new StringContent(
                    @"[{""symbol"":""BNBBTC"",""origClientOrderId"":""dYJEVoHBmZ9wO55DWErawG"",""orderId"":1369,
                            ""orderListId"":-1,""clientOrderId"":""oy60PoMjhqSDSA8JrbAdbb"",""price"":""0.00100000"",
                            ""origQty"":""0.10000000"",""executedQty"":""0.00000000"",""cummulativeQuoteQty"":""0.00000000"",
                            ""status"":""CANCELED"",""timeInForce"":""GTC"",""type"":""LIMIT"",""side"":""BUY""},
                            {""symbol"":""BNBBTC"",""origClientOrderId"":""d81bitzsSWPjprIJhgHxR1"",""orderId"":1371,
                            ""orderListId"":-1,""clientOrderId"":""oy60PoMjhqSDSA8JrbAdbb"",""price"":""0.00100000"",""origQty"":""0.10000000"",
                            ""executedQty"":""0.00000000"",""cummulativeQuoteQty"":""0.00000000"",""status"":""CANCELED"",""timeInForce"":""GTC"",
                            ""type"":""LIMIT"",""side"":""BUY""},
                            {""symbol"":""BNBBTC"",""origClientOrderId"":""eE5TpVjDdljT3Q6121rbkD"",""orderId"":1373,""orderListId"":-1,
                              ""clientOrderId"":""oy60PoMjhqSDSA8JrbAdbb"",""price"":""0.00100000"",""origQty"":""0.10000000"",
                              ""executedQty"":""0.00000000"",""cummulativeQuoteQty"":""0.00000000"",""status"":""CANCELED"",
                            ""timeInForce"":""GTC"",""type"":""LIMIT"",""side"":""BUY""}]")
            }))
            .Verifiable();
            HttpClient httpClient = new HttpClient(_httpMessageHandlerMock.Object);

            _connectionAdapter.HttpClient = httpClient;
            Binance subjectUnderTest = new Binance();

            subjectUnderTest.ConnectionAdapter = _connectionAdapter;
            Product product = new Product();

            product.ID = "BNBBTC";
            //Act
            List <BinanceOrder> binanceOrders = subjectUnderTest.CancelOrdersAsync(product).Result;

            //Assert
            Assert.IsNotNull(binanceOrders);
        }