Exemplo n.º 1
0
        public void CashNormalStrategyTestMethod()
        {
            double money = 999;

            CashContext context = new CashContext(new CashNormal());

            Assert.AreEqual(money, context.GetResule(money));
        }
Exemplo n.º 2
0
        public void CashRebateStrategyTestMethod()
        {
            double money = 999;

            double rebate = 0.95d;

            CashContext context = new CashContext(new CashRebate(rebate));

            Assert.AreEqual(money * rebate, context.GetResule(money));
        }
Exemplo n.º 3
0
        public void CashReturnStrategyTestMethod()
        {
            double money = 999;

            double      condition = 100d;
            double      _return   = 10;
            CashContext context   = new CashContext(new CashReturn(condition, _return));
            double      expected  = money < condition ? money : money - Math.Floor(money / condition) * _return;

            Assert.AreEqual(expected, context.GetResule(money));
        }