public void TestCurrencyExchange_ExchangeRateChange() { //arrange CurrencyExchange exchange = new CurrencyExchange(new List <string> { "AAA", "BBB", "CCC" }); double expectedResult = 2.50; //act exchange.SpecifyExchangeRate("AAABBB", 6.50); exchange.SpecifyExchangeRate("AAABBB", 2.50); double actualResult = exchange.ExchangeRates["AAABBB"]; //assert Assert.AreEqual(expectedResult, actualResult); }
public void TestCurrencyExchange_CalculateExchangedRate_CheckAfterChange() { //arrange CurrencyExchange exchange = new CurrencyExchange(new List <string> { "AAA", "BBB", "CCC" }); Dictionary <string, double> expectedResult = new Dictionary <string, double>(); expectedResult.Add("AAABBB", 2.50); //act exchange.SpecifyExchangeRate("AAABBB", 6.50); exchange.SpecifyExchangeRate("AAABBB", 2.50); Dictionary <string, double> actualResult = exchange.ExchangeRates; //assert CollectionAssert.AreEqual(expectedResult, actualResult); }
public void TestCurrencyExchange_ExchangeRateNegativeRate_Exception() { //arrange CurrencyExchange exchange = new CurrencyExchange(new List <string> { "AAA", "BBB", "CCC" }); //act, assert Assert.ThrowsException <ArgumentException>(() => exchange.SpecifyExchangeRate("AAABBB", -5.50)); }
public void TestCurrencyExchange_ExchangeRateCurrencyCrossDoesNotExist_Exception() { //arrange CurrencyExchange exchange = new CurrencyExchange(new List <string> { "AAA", "BBB", "CCC" }); //act, assert Assert.ThrowsException <ArgumentException>(() => exchange.SpecifyExchangeRate("AAADDD", 3.45)); }
public void TestCurrencyExchange_CalculateExchangedRateAmountNotPositive_Exception() { //arrange CurrencyExchange exchange = new CurrencyExchange(new List <string> { "AAA", "BBB", "CCC" }); //act exchange.SpecifyExchangeRate("AAABBB", 6.50); //assert Assert.ThrowsException <ArgumentException>(() => exchange.CalculateExchangedRate("AAABBB", "AAA", -200)); }
public void TestCurrencyExchange_ExchangeRateMixAutomatic_NoException() { //arrange CurrencyExchange exchange = new CurrencyExchange(new List <string> { "AAA", "BBB", "CCC" }); double expectedResult = 2.50 / 6.50; //act exchange.SpecifyExchangeRate("AAABBB", 2.50); exchange.SpecifyExchangeRate("AAACCC", 6.50); //double actualResult = exchange.ExchangeRates["BBBCCC"]; //assert string output = ""; foreach (string s in exchange.ExchangeRates.Keys) { TestContext.WriteLine(s); } //Assert.AreEqual(expectedResult, actualResult); }