Пример #1
0
        public void UpdateAccounts_ShouldReturnAccounts_WhenAccountExists()
        {
            //Arrange
            _httpMessageHandlerMock
            .Protected()
            .Setup <Task <HttpResponseMessage> >("SendAsync", ItExpr.IsAny <HttpRequestMessage>(),
                                                 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.IsAny <HttpRequestMessage>(),
                                                 ItExpr.IsAny <CancellationToken>())
            .Returns(Task.FromResult(new HttpResponseMessage(HttpStatusCode.OK)
            {
                StatusCode = HttpStatusCode.OK,
                Content    = new StringContent(
                    @"{""makerCommission"": 10,""takerCommission"": 10,""buyerCommission"": 0,""sellerCommission"": 0,
                        ""canTrade"": true,""canWithdraw"": true,""canDeposit"": true,""updateTime"": 1561284536404,""accountType"": ""MARGIN"",
                        ""balances"": [
                        {""asset"": ""BTC"",""free"": ""0.00000000"",""locked"": ""0.00000000""},
                        {""asset"": ""LTC"",""free"": ""0.00000000"",""locked"": ""0.00000000""},
                        {""asset"": ""ETH"",""free"": ""0.00000000"",""locked"": ""0.00000000""}],
                        ""permissions"": [""SPOT""]}")
            }))
            .Verifiable();
            HttpClient httpClient = new HttpClient(_httpMessageHandlerMock.Object);

            _connectionAdapter.HttpClient = httpClient;
            Binance subjectUnderTest = new Binance {
                ConnectionAdapter = _connectionAdapter
            };

            //Act
            subjectUnderTest.UpdateAccountsAsync().Wait();
            Assert.IsNotNull(subjectUnderTest.BinanceAccount);
        }