예제 #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));
        }
예제 #2
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));
        }