コード例 #1
0
            public void TestReduceMoney()
            {
                Bank bank = new Bank();

                Money actual = bank.Reduce(Money.Dollar(1), "USD");

                Assert.Equal(Money.Dollar(1), actual);
            }
コード例 #2
0
            public void TestReduceSum()
            {
                Expression sum = new Sum(Money.Dollar(3), Money.Dollar(4));
                Bank bank = new Bank();

                Money actual = bank.Reduce(sum, "USD");

                Assert.Equal(Money.Dollar(7), actual);
            }
コード例 #3
0
            public void TestReduceMoneyDifferentCurrency()
            {
                Bank bank = new Bank();
                bank.AddRate("CHF", "USD", 2);

                Money actual = bank.Reduce(Money.Franc(2), "USD");

                Assert.Equal(Money.Dollar(1), actual);
            }
コード例 #4
0
        public void TestSumTimes()
        {
            Expression fiveBucks = Money.Dollar(5);
            Expression tenFrancs = Money.Franc(10);
            Bank bank = new Bank();
            bank.AddRate("CHF", "USD", 2);
            Expression sum = new Sum(fiveBucks, tenFrancs).Times(2);

            Money actual = bank.Reduce(sum, "USD");

            Assert.Equal(Money.Dollar(20), actual);
        }
コード例 #5
0
            public void TestSimpleAddition()
            {
                Money five = Money.Dollar(5);
                Expression sum = five.Plus(five);
                var bank = new Bank();
                Money reduced = bank.Reduce(sum, "USD");

                Assert.Equal(Money.Dollar(10), reduced);
            }
コード例 #6
0
            public void TestMixedAddition()
            {
                Expression fiveBucks = Money.Dollar(5);
                Expression tenFrancs = Money.Franc(10);
                Bank bank = new Bank();
                bank.AddRate("CHF", "USD", 2);

                Money actual = bank.Reduce(fiveBucks.Plus(tenFrancs), "USD");

                Assert.Equal(Money.Dollar(10), actual);
            }