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 Ctor_CustomRateFactory_AddInstancesOfCustomExchangeRate() { var subject = new TabulatedExchangeRateProvider((from, to, rate) => new CustomExchangeRate(from, to, rate)); ExchangeRate added = subject.Add(CurrencyIsoCode.AED, CurrencyIsoCode.AFN, 1); Assert.That(added.GetType(), Is.SameAs(typeof(CustomExchangeRate))); }
public void Ctor_DefaultRateFactory_AddInstancesOfExchangeRate() { var subject = new TabulatedExchangeRateProvider(); ExchangeRate added = subject.Add(CurrencyIsoCode.AED, CurrencyIsoCode.AFN, 1); Assert.That(added.GetType(), Is.SameAs(typeof(ExchangeRate))); }
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_AddsTheRate_WithTheData() { var subject = new TabulatedExchangeRateProvider(); ExchangeRate added = subject.Add(CurrencyIsoCode.AED, CurrencyIsoCode.AFN, 1.5m); Assert.That(added.From, Is.EqualTo(CurrencyIsoCode.AED)); Assert.That(added.To, Is.EqualTo(CurrencyIsoCode.AFN)); Assert.That(added.Rate, Is.EqualTo(1.5m)); }
public void InitSubject() { _as20110519 = new TabulatedExchangeRateProvider((from, to, rate) => new FiveDecimalsArithmetic(from, to, rate)); _as20110519.Add(CurrencyIsoCode.USD, CurrencyIsoCode.USD, 1m); _as20110519.Add(CurrencyIsoCode.USD, CurrencyIsoCode.EUR, 0.70155m); _as20110519.Add(CurrencyIsoCode.USD, CurrencyIsoCode.GBP, 0.61860m); _as20110519.Add(CurrencyIsoCode.EUR, CurrencyIsoCode.EUR, 1m); _as20110519.Add(CurrencyIsoCode.EUR, CurrencyIsoCode.USD, 1.42542m); _as20110519.Add(CurrencyIsoCode.EUR, CurrencyIsoCode.GBP, 0.88176m); _as20110519.Add(CurrencyIsoCode.GBP, CurrencyIsoCode.GBP, 1m); _as20110519.Add(CurrencyIsoCode.GBP, CurrencyIsoCode.EUR, 1.13409m); _as20110519.Add(CurrencyIsoCode.GBP, CurrencyIsoCode.USD, 1.61656m); }
public void InitSubject() { _as20110519 = new TabulatedExchangeRateProvider(); _as20110519.Add(CurrencyIsoCode.USD, CurrencyIsoCode.USD, 1m); _as20110519.Add(CurrencyIsoCode.USD, CurrencyIsoCode.EUR, 0.70155m); _as20110519.Add(CurrencyIsoCode.USD, CurrencyIsoCode.GBP, 0.61860m); _as20110519.Add(CurrencyIsoCode.EUR, CurrencyIsoCode.EUR, 1m); _as20110519.Add(CurrencyIsoCode.EUR, CurrencyIsoCode.USD, 1.42542m); _as20110519.Add(CurrencyIsoCode.EUR, CurrencyIsoCode.GBP, 0.88176m); _as20110519.Add(CurrencyIsoCode.GBP, CurrencyIsoCode.GBP, 1m); _as20110519.Add(CurrencyIsoCode.GBP, CurrencyIsoCode.EUR, 1.13409m); _as20110519.Add(CurrencyIsoCode.GBP, CurrencyIsoCode.USD, 1.61656m); }
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 Configuring_Provider() { var customProvider = new TabulatedExchangeRateProvider(); customProvider.Add(CurrencyIsoCode.EUR, CurrencyIsoCode.USD, 0); ExchangeRateProvider.Factory = () => customProvider; var tenEuro = new Money(10m, CurrencyIsoCode.EUR); var zeroDollars = tenEuro.Convert().To(CurrencyIsoCode.USD); // go back to default ExchangeRateProvider.Factory = ExchangeRateProvider.Default; }