public async Task WhenRateIsTwoAndPriceIsOne_PriceIsMultipliedByRateTwo_ReturnsNewPriceTwo() { //arrange var testPrice = 1; _rateRetrieverMock.Setup(rateRetriever => rateRetriever.Rate("GBP", "USD")).ReturnsAsync(2); var currencyConverter = new CurrencyConverter(_rateRetrieverMock.Object); //act var convertedPrice = await currencyConverter.ConvertedPrice(testPrice, "GBP", "USD"); //assert Assert.AreEqual(2, convertedPrice); }
public async Task WhenRateIsTwopPointFourAndPriceIsOnePointFiveOne_PriceIsMultipliedByRateTwo_ReturnsNewPriceTwo() { //arrange var testPrice = (decimal)1.51; _rateRetrieverMock.Setup(rateRetriever => rateRetriever.Rate("GBP", "USD")).ReturnsAsync((decimal)2.4); var currencyConverter = new CurrencyConverter(_rateRetrieverMock.Object); //act var convertedPrice = await currencyConverter.ConvertedPrice(testPrice, "GBP", "USD"); //assert Assert.AreEqual(3.624, convertedPrice); }
public async Task WhenRateIsOne_PriceIsUnchanged_ReturnsSubmittedPriceValue() { //arrange var testPrice = 1; _rateRetrieverMock.Setup(rateRetriever => rateRetriever.Rate("GBP", "GBP")).ReturnsAsync((decimal)1); var currencyConverter = new CurrencyConverter(_rateRetrieverMock.Object); //act var convertedPrice = await currencyConverter.ConvertedPrice(testPrice, "GBP", "GBP"); //assert Assert.AreEqual(testPrice, convertedPrice); }