Exemplo n.º 1
0
        public void _02_Creer_une_classe_SumCommand_avec_une_methode_Do_et_Undo()
        {
            Calculator calculator = new Calculator();

            SumCommand sum = new SumCommand(calculator, 10);

            Assert.Equal(0, calculator.Result);

            sum.Do();

            Assert.Equal(10, calculator.Result);

            sum.Undo();

            Assert.Equal(0, calculator.Result);
        }
Exemplo n.º 2
0
        public void _03_Creer_une_classe_MultiplyCommand_avec_une_methode_Do_et_Undo()
        {
            Calculator calculator = new Calculator();

            SumCommand sum = new SumCommand(calculator, 5);

            MultiplyCommand multiply = new MultiplyCommand(calculator, 10);

            Assert.Equal(0, calculator.Result);

            sum.Do();

            Assert.Equal(5, calculator.Result);

            multiply.Do();

            Assert.Equal(50, calculator.Result);

            multiply.Undo();

            Assert.Equal(5, calculator.Result);
        }