Example #1
0
        public void GetRate_DateFromFuture_ExceptionThrown()
        {
            var client = new Mock <IBankGovUaClient>();
            UahCurrencyRateService service = new UahCurrencyRateService(client.Object);

            Assert.ThrowsAsync <ArgumentOutOfRangeException>(() => service.GetRate(DateTime.MaxValue));
        }
Example #2
0
        public void GetRate_EmptyResponse_ExceptionThrown()
        {
            var client = new Mock <IBankGovUaClient>();
            List <BankGovUaRateResponse> response = new List <BankGovUaRateResponse>();

            client.Setup(p => p.Exchange(It.IsAny <DateTime>())).ReturnsAsync(response);
            UahCurrencyRateService service = new UahCurrencyRateService(client.Object);

            Assert.ThrowsAsync <Exception>(() => service.GetRate(DateTime.Now));
        }
Example #3
0
        public async void GetRate_CorrectInput_ReturnResult(DateTime date, List <BankGovUaRateResponse> response)
        {
            var client = new Mock <IBankGovUaClient>();

            client.Setup(p => p.Exchange(It.IsAny <DateTime>())).ReturnsAsync(response);
            UahCurrencyRateService service = new UahCurrencyRateService(client.Object);

            decimal expected = 0.02534M;
            decimal actual   = await service.GetRate(date);

            Assert.Equal(expected, actual, 5);
        }