Exemple #1
0
        public void CurrencyConverter_ConvertThirtyUSDToUSD_ValueShouldNotChange()
        {
            // Arrange
            var countries = new List <Country>
            {
                new Country()
                {
                    CountryName = "United States", CurrencyAbbrv = "USD", CurrencyName = "US Dollar", ExchangeRateToUSD = 1
                },
                new Country()
                {
                    CountryName = "Canada", CurrencyAbbrv = "CAD", CurrencyName = "Candadian Dollar", ExchangeRateToUSD = 0.75
                },
                new Country()
                {
                    CountryName = "Russia", CurrencyAbbrv = "RUB", CurrencyName = "Russian Ruble", ExchangeRateToUSD = 0.015
                },
                new Country()
                {
                    CountryName = "Japan", CurrencyAbbrv = "JPY", CurrencyName = "Japan Yen", ExchangeRateToUSD = 0.75
                },
                new Country()
                {
                    CountryName = "England", CurrencyAbbrv = "GBP", CurrencyName = "Great British Pound", ExchangeRateToUSD = 1.33
                },
            };
            var db = new Mock <IDataContext>();

            db.Setup(x => x.Counties).Returns(countries.AsQueryable());

            ICountryRepository countryRepo = new CountryRepository(db.Object);
            ICurrencyConverter sut         = new CurrencyConverter(countryRepo);
            double             value       = 30d;

            // Act
            var convertedValue = sut.ConvertToUSD("USD", value);

            // Assert
            Assert.AreEqual(convertedValue, value);
        }