コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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));
        }
コード例 #4
0
        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));
        }
コード例 #5
0
        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));
        }
コード例 #6
0
        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);
        }