示例#1
0
        public void Max_ThrowsAnArgumentException_WhenAllMoniesAreNotInTheSameCurrency()
        {
            // Arrange
            var monies = new List <IMoney> {
                _moneyGbp10, _moneyUsd20
            };

            // Act
            var exception = Assert.Throws <ArgumentException>(() => _moneyCalculator.Max(monies));

            // Assert
            Assert.That("All monies are not in the same currency", Is.EqualTo(exception?.Message));
        }
        public void MaxforMoniesinDifferentCurrenciesTest()
        {
            IMoneyCalculator moneyCalculator = new MoneyCalculator();
            var monies = GetMoneyListWithMultipleCurrencies();

            Assert.Throws <ArgumentException>(() => moneyCalculator.Max(monies));
        }
        public void MaxFailNullRefException()
        {
            IEnumerable <IMoney> monies;
            MoneyCalculator      moneyCalc = new MoneyCalculator();
            IMoney max;

            Money.Money[] moneyList = null;

            monies = moneyCalc.GetMoneyEnumList(moneyList);
            Console.WriteLine(moneyCalc.ShowMoneyList("Current List: {", monies));
            max = moneyCalc.Max(monies);
            Console.WriteLine(moneyCalc.ShowMoneyList("Max Amount: {", max));
        }
        public void MaxFailArgsException()
        {
            IEnumerable <IMoney> monies;
            MoneyCalculator      moneyCalc = new MoneyCalculator();
            IMoney max;

            Money.Money[] moneyList = new Money.Money[]
            {
                new Money.Money(10, "GBP"),
                new Money.Money(20, "EUR"),
                new Money.Money(30, "GBP")
            };

            monies = moneyCalc.GetMoneyEnumList(moneyList);
            Console.WriteLine(moneyCalc.ShowMoneyList("Current List: {", monies));
            max = moneyCalc.Max(monies);
            Console.WriteLine(moneyCalc.ShowMoneyList("Max Amount: {", max));
        }
示例#5
0
        public static void Main()
        {
            IMoney money1 = new Money(10.00m, CurrencyCodes.GBP);
            IMoney money2 = new Money(50.00m, CurrencyCodes.GBP);
            IMoney money3 = new Money(20.00m, CurrencyCodes.GBP);

            IMoney money4 = new Money(75.00m, CurrencyCodes.USD);

            IMoney money5 = new Money(15.00m, CurrencyCodes.EUR);
            IMoney money6 = new Money(5.00m, CurrencyCodes.EUR);

            IMoneyCalculator moneyCalculator = new MoneyCalculator();

            var monies = new List <IMoney> {
                money1, money2, money3
            };
            var maxResult = moneyCalculator.Max(monies);

            var moniesWithDifferentCurrencies = new List <IMoney> {
                money1, money2, money3, money4, money5, money6
            };
            var sumPerCurrencyResult = moneyCalculator.SumPerCurrency(moniesWithDifferentCurrencies);
        }
        public void MaxTestforNullMonies()
        {
            IMoneyCalculator moneyCalculator = new MoneyCalculator();

            Assert.Throws <ArgumentNullException>(() => moneyCalculator.Max(null));
        }