public void Get_FromEUR_CorrectRate(CurrencyIsoCode to, decimal rate)
        {
            ExchangeRate fromEuro = _as20110519.Get(CurrencyIsoCode.EUR, to);

            Assert.That(fromEuro.From, Is.EqualTo(CurrencyIsoCode.EUR));
            Assert.That(fromEuro.To, Is.EqualTo(to));
            Assert.That(fromEuro.Rate, Is.EqualTo(rate));
        }
        public void Get_FromEUR_CorrectRate(CurrencyIsoCode to, decimal rate)
        {
            ExchangeRate fromEuro = _as20110519.Get(CurrencyIsoCode.EUR, to);

            Assert.That(fromEuro.From, Is.EqualTo(CurrencyIsoCode.EUR));
            Assert.That(fromEuro.To, Is.EqualTo(to));
            Assert.That(fromEuro.Rate, Is.EqualTo(rate)
                        .Within(0.00001m), "as it was built from USD, EUR direct rates have more decimals");
        }
        public void Add_IdentityRatesForBaseCurrency_NotAdded()
        {
            var subject = new TabulatedExchangeRateProvider();

            subject.Add(CurrencyIsoCode.AED, CurrencyIsoCode.AFN, 1.5m);

            Assert.That(() => subject.Get(CurrencyIsoCode.AED, CurrencyIsoCode.AED), Throws.InstanceOf <KeyNotFoundException>());
        }
        public void Get_NonExistingRate_Exception()
        {
            var subject = new TabulatedExchangeRateProvider();

            subject.Add(CurrencyIsoCode.AED, CurrencyIsoCode.AFN, 1.5m);

            Assert.That(() => subject.Get(CurrencyIsoCode.USD, CurrencyIsoCode.AFN), Throws.InstanceOf <KeyNotFoundException>());
        }
        public void Add_ExistingRates_AreOverwritten()
        {
            var subject = new TabulatedExchangeRateProvider();

            subject.Add(CurrencyIsoCode.AED, CurrencyIsoCode.AFN, 1.5m);
            subject.Add(CurrencyIsoCode.AED, CurrencyIsoCode.AFN, 2m);

            ExchangeRate overwritten = subject.Get(CurrencyIsoCode.AED, CurrencyIsoCode.AFN);

            Assert.That(overwritten.Rate, Is.EqualTo(2m));
        }
        public void Get_ExistingRate_RateReturned()
        {
            var subject = new TabulatedExchangeRateProvider();

            subject.Add(CurrencyIsoCode.AED, CurrencyIsoCode.AFN, 1.5m);

            ExchangeRate existing = subject.Get(CurrencyIsoCode.AED, CurrencyIsoCode.AFN);

            Assert.That(existing.From, Is.EqualTo(CurrencyIsoCode.AED));
            Assert.That(existing.To, Is.EqualTo(CurrencyIsoCode.AFN));
            Assert.That(existing.Rate, Is.EqualTo(1.5m));
        }
        public void MultiAdd_IdentityRatesForQuoteCurrency_Added()
        {
            var subject = new TabulatedExchangeRateProvider();

            subject.MultiAdd(CurrencyIsoCode.AED, CurrencyIsoCode.AFN, 1.5m);

            var identity = subject.Get(CurrencyIsoCode.AFN, CurrencyIsoCode.AFN);

            Assert.That(identity.From, Is.EqualTo(CurrencyIsoCode.AFN));
            Assert.That(identity.To, Is.EqualTo(CurrencyIsoCode.AFN));
            Assert.That(identity.Rate, Is.EqualTo(1m));
        }
        public void MultiAdd_InverseRate_Added()
        {
            var subject = new TabulatedExchangeRateProvider();

            subject.MultiAdd(CurrencyIsoCode.AED, CurrencyIsoCode.AFN, 1.5m);

            var inverse = subject.Get(CurrencyIsoCode.AFN, CurrencyIsoCode.AED);

            Assert.That(inverse.From, Is.EqualTo(CurrencyIsoCode.AFN));
            Assert.That(inverse.To, Is.EqualTo(CurrencyIsoCode.AED));
            Assert.That(inverse.Rate, Is.EqualTo(0.66m).Within(0.0067m));
        }