public void When_ApiNotReachable_Expect_AggregateException()
        {
            // arrange
            var mockHttp = new MockHttpMessageHandler();

            mockHttp.When($"*{Endpoints.PlatformStatus}")
            .Respond(new ExceptionThrowingContent(
                         new HttpRequestException("An error occured while sending the request.")));

            // act
            var bfClient       = new BitfinexApiClient(Config.ApiKey, Config.SecretKey, new HttpClient(mockHttp));
            var platformStatus = bfClient.GetPlatformStatusAsync().Result;
        }
        public void When_ApiReturnsPlatformNotWorking_OperativeEqualsZero()
        {
            // arrange
            var mockHttp = new MockHttpMessageHandler();

            mockHttp.When($"*{Endpoints.PlatformStatus}")
            .Respond(MediaTypes.ApplicationJson, "[0]");

            // act
            var bfClient       = new BitfinexApiClient(Config.ApiKey, Config.SecretKey, new HttpClient(mockHttp));
            var platformStatus = bfClient.GetPlatformStatusAsync().Result;

            // assert
            Assert.AreEqual(platformStatus.Operative, 0);
        }
        public void When_ApiReturnsNoValue_PlatformStatusIsNull()
        {
            // arrange
            var mockHttp = new MockHttpMessageHandler();

            mockHttp.When($"*{Endpoints.PlatformStatus}")
            .Respond(MediaTypes.ApplicationJson, "[]");

            // act
            var bfClient       = new BitfinexApiClient(Config.ApiKey, Config.SecretKey, new HttpClient(mockHttp));
            var platformStatus = bfClient.GetPlatformStatusAsync().Result;

            // assert
            Assert.IsNull(platformStatus);
        }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            BitfinexApiClient bfRestClient = new BitfinexApiClient(Config.ApiKey, Config.SecretKey, new HttpClient());

            var platformStatus = bfRestClient.GetPlatformStatusAsync().Result;

            Console.WriteLine($"API State (1=up / 0=down): {platformStatus.Operative}");

            var alerts = bfRestClient.GetAlertsAsync().Result;

            Console.WriteLine("Alerts:");
            alerts.ForEach(alert => Console.WriteLine(alert.ToString()));

            var wallets = bfRestClient.GetWalletsAsync().Result;

            Console.WriteLine("Wallets:");
            wallets.ForEach(wallet => Console.WriteLine(wallet.ToString()));

            Console.ReadLine();
        }