コード例 #1
0
        public void Given_CurrenciesAndDate_When_GetAsyncInvoked_Then_resultWithExchangeRateRetrived()
        {
            string currencyFrom = "USD", currencyTo = "EUR";
            var    date = DateTime.Today;

            var result = _serviceUnderTest.GetAsync(currencyFrom, currencyTo, date).Result;

            Assert.IsNotNull(result);
            Assert.AreEqual(currencyFrom, result.From);
            Assert.AreEqual(currencyTo, result.To);
            Assert.AreNotEqual(result.Rate, 0);
            Assert.AreEqual(date, result.Date);
        }
コード例 #2
0
        public async Task <HealthCheckResult> CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = default)
        {
            try
            {
                var exchangeRate = await exchangeRateService.GetAsync("A", "CHF");

                return(HealthCheckResult.Healthy($"kurs: {exchangeRate.Rates[0].Mid}"));
            }
            catch (Exception e)
            {
                return(HealthCheckResult.Degraded("API nie odpowiada", e));
            }
        }