Exemplo n.º 1
0
        public async Task HttpResponseIsDeserialized()
        {
            var result = new ExchangeResponseStub
            {
                TestString = "Test",
                TestDouble = 1234,
            };

            var response = "{\"jsonrpc\":\"2.0\",\"result\":" +
                           result.ToJson() +
                           ",\"id\":1}";

            _httpMessageHandler.WithReturnContent(response);
            using var local = new ExchangeService(_session, _log);
            local.WithHandler(_httpMessageHandler.Build());
            var actual = await local.SendAsync <ExchangeResponseStub>("endpoint", "method", "parameters");

            Assert.Equal(result.ToJson(), actual.ToJson());
        }
Exemplo n.º 2
0
        public async Task HttpResponseIsLogged(string responseString)
        {
            var result = new ExchangeResponseStub
            {
                TestString = responseString,
                TestDouble = 1234,
            };

            var response = "{\"jsonrpc\":\"2.0\",\"result\":" +
                           result.ToJson() +
                           ",\"id\":1}";

            _httpMessageHandler.WithReturnContent(response);
            using var local = new ExchangeService(_session, _log);
            local.WithHandler(_httpMessageHandler.Build());

            var actual = await local.SendAsync <ExchangeResponseStub>("endpoint", "method", "parameters");

            var expected = $"Betfair API responded: {{\"result\":{actual.ToJson()}}}.";

            Assert.Equal(expected, _log.LastMessage);
        }