public void ExchangeRate_CanBeExtendedTo_SupportCustomInversions() { var stock = new ExchangeRate(CurrencyIsoCode.EUR, CurrencyIsoCode.USD, 1.11111m); var noOp = new ExtendsInvert(CurrencyIsoCode.EUR, CurrencyIsoCode.USD, 1.11111m); Assert.That(stock.Invert(), Is.Not.EqualTo(noOp.Invert())); }
public void Get_ToEURInverse_CorrectRate(CurrencyIsoCode from, decimal rate) { ExchangeRate toEuro = _as20110519.Get(from, CurrencyIsoCode.EUR); ExchangeRate inversed = toEuro.Invert(); Assert.That(inversed.From, Is.EqualTo(CurrencyIsoCode.EUR)); Assert.That(inversed.To, Is.EqualTo(from)); Assert.That(inversed.Rate, Is.EqualTo(rate)); }
public void Invert_SwappedCurrencies_AndInvertedRate() { var subject = new ExchangeRate(CurrencyIsoCode.EUR, CurrencyIsoCode.USD, 1.25m); ExchangeRate inverted = subject.Invert(); Assert.That(inverted.From, Is.EqualTo(CurrencyIsoCode.USD)); Assert.That(inverted.To, Is.EqualTo(CurrencyIsoCode.EUR)); Assert.That(inverted.Rate, Is.EqualTo(0.8m)); }
public void Invert_Switches_The_Currencies() { var original = new ExchangeRate(EUR, USD, 1.141233m); var sut = original.Invert(); sut.From.Should().Be(USD); sut.To.Should().Be(EUR); sut.Rate.Should().BeApproximately(0.8762452540366428m, 0.00000001m); }
public void Get_ToEURInverse_CorrectRate(CurrencyIsoCode from, decimal rate) { ExchangeRate toEuro = _as20110519.Get(from, CurrencyIsoCode.EUR); ExchangeRate inversed = toEuro.Invert(); Assert.That(inversed.From, Is.EqualTo(CurrencyIsoCode.EUR)); Assert.That(inversed.To, Is.EqualTo(from)); Assert.That(inversed.Rate, Is.EqualTo(rate) .Within(0.00001m), "within 5 decimals due to precision of Invert()"); }
public void Get_FromEURInverse_CorrectRate(CurrencyIsoCode to, decimal rate) { ExchangeRate fromEuro = _as20110519.Get(CurrencyIsoCode.EUR, to); ExchangeRate inversed = fromEuro.Invert(); Assert.That(inversed.From, Is.EqualTo(to)); Assert.That(inversed.To, Is.EqualTo(CurrencyIsoCode.EUR)); Assert.That(inversed.Rate, Is.EqualTo(rate) .Within(0.00001m), "within 5 decimals error as Invert() uses decimal arithmetic"); }
public void Get_FromEURInverse_CorrectRate(CurrencyIsoCode to, decimal rate) { ExchangeRate fromEuro = _as20110519.Get(CurrencyIsoCode.EUR, to); ExchangeRate inversed = fromEuro.Invert(); Assert.That(inversed.From, Is.EqualTo(to)); Assert.That(inversed.To, Is.EqualTo(CurrencyIsoCode.EUR)); Assert.That(inversed.Rate, Is.EqualTo(rate) .Within(0.00001), "for some reason, despite using 5-digits arithmetic 1.13409m is represented as 1.1341m so a error marging is needed"); }
public void Invert_IsPure() { var subject = new ExchangeRate(CurrencyIsoCode.EUR, CurrencyIsoCode.USD, 1.25m); ExchangeRate inverted = subject.Invert(); Assert.That(inverted, Is.Not.SameAs(subject)); Assert.That(subject.From, Is.EqualTo(CurrencyIsoCode.EUR)); Assert.That(subject.To, Is.EqualTo(CurrencyIsoCode.USD)); Assert.That(subject.Rate, Is.EqualTo(1.25m)); }