public void GetRate_DateFromFuture_ExceptionThrown() { var client = new Mock <INationalBankKzClient>(); KztCurrencyRateService service = new KztCurrencyRateService(client.Object); Assert.ThrowsAsync <ArgumentOutOfRangeException>(() => service.GetRate(DateTime.MaxValue)); }
public void GetRate_EmptyResponse_ExceptionThrown() { var client = new Mock <INationalBankKzClient>(); NbRatesResponse response = new NbRatesResponse(); client.Setup(p => p.GetRates(It.IsAny <DateTime>())).ReturnsAsync(response); KztCurrencyRateService service = new KztCurrencyRateService(client.Object); Assert.ThrowsAsync <Exception>(() => service.GetRate(DateTime.Now)); }
public async void GetRate_CorrectInput_ReturnResult(DateTime date, NbRatesResponse response) { var client = new Mock <INationalBankKzClient>(); client.Setup(p => p.GetRates(It.IsAny <DateTime>())).ReturnsAsync(response); KztCurrencyRateService service = new KztCurrencyRateService(client.Object); decimal expected = 5.8M; decimal actual = await service.GetRate(date); Assert.Equal(expected, actual, 1); }