Exemplo n.º 1
0
        public void TestAppendingEmptyExchangeRate()
        {
            //Arrange
            var firstRateList = new Dictionary <string, decimal>
            {
                { "BRL", (decimal)39471.159 },
                { "EUR", (decimal)8708.442 },
                { "USD", (decimal)9558.551 }
            };
            var mainExchageRate = new ExchangeRatesList()
            {
                BaseCurrencySymbol = "BTC", CurrenciesRates = new Dictionary <string, decimal>(firstRateList)
            };
            var SecondExchageRate = new ExchangeRatesList()
            {
                BaseCurrencySymbol = "EUR"
            };

            //Act
            mainExchageRate.Append(SecondExchageRate);


            //Assert
            mainExchageRate.Should().NotBeNull();
            mainExchageRate.BaseCurrencySymbol.Should().Be("BTC");
            mainExchageRate.CurrenciesRates.Should().HaveCount(3).And.ContainKeys(firstRateList.Keys);;
            mainExchageRate.CurrenciesRates["BRL"].Should().Be((decimal)(39471.159));
            mainExchageRate.CurrenciesRates["USD"].Should().Be((decimal)(9558.551));
        }
Exemplo n.º 2
0
        public void TestAppendingExchangeRateWithBaseCurrencyNotInMainListCurrenciesRates()
        {
            //Arrange
            var firstRateList = new Dictionary <string, decimal>
            {
                { "BRL", (decimal)39471.159 },
                { "EUR", (decimal)8708.442 },
                { "USD", (decimal)9558.551 }
            };
            var mainExchageRate = new ExchangeRatesList()
            {
                BaseCurrencySymbol = "BTC", CurrenciesRates = new Dictionary <string, decimal>(firstRateList)
            };

            //Act
            var SecondRateList = new Dictionary <string, decimal>
            {
                { "CAD", (decimal)1.5344 },
                { "HKD", (decimal)9.29 },
                { "AUD", (decimal)1.5761 },
                { "USD", (decimal)1.1983 }
            };
            var SecondExchageRate = new ExchangeRatesList()
            {
                BaseCurrencySymbol = "MYR", CurrenciesRates = new Dictionary <string, decimal>(SecondRateList)
            };

            //Assert
            Action act = () => mainExchageRate.Append(SecondExchageRate);

            act.Should().Throw <Exception>().Where(e => e.Message.StartsWith("The ExchangeRatesList can't be appended"));
        }
Exemplo n.º 3
0
        public void TestAppendingExchangeRate_WithOverwrite()
        {
            //Arrange
            var firstRateList = new Dictionary <string, decimal>
            {
                { "BRL", (decimal)39471.159 },
                { "EUR", (decimal)8708.442 },
                { "USD", (decimal)9558.551 }
            };
            var mainExchageRate = new ExchangeRatesList()
            {
                BaseCurrencySymbol = "BTC", CurrenciesRates = new Dictionary <string, decimal>(firstRateList)
            };

            var SecondRateList = new Dictionary <string, decimal>
            {
                { "CAD", (decimal)1.5344 },
                { "HKD", (decimal)9.29 },
                { "AUD", (decimal)1.5761 },
                { "USD", (decimal)1.3 }
            };
            var SecondExchageRate = new ExchangeRatesList()
            {
                BaseCurrencySymbol = "EUR", CurrenciesRates = new Dictionary <string, decimal>(SecondRateList)
            };

            //Act
            mainExchageRate.Append(SecondExchageRate, true);

            //Assert
            mainExchageRate.Should().NotBeNull();
            mainExchageRate.BaseCurrencySymbol.Should().Be("BTC");
            mainExchageRate.CurrenciesRates.Should().HaveCount(6).And.ContainKeys(SecondRateList.Keys);
            mainExchageRate.CurrenciesRates["CAD"].Should().Be((decimal)(1.5344 * 8708.442));
            mainExchageRate.CurrenciesRates["USD"].Should().Be((decimal)(1.3 * 8708.442));
        }