public void TestCompositeCommand() { var ba = new BankAccount(); var deposit = new BankAccountCommand(ba, BankAccountCommand.Action.Deposit, 100); var withdraw = new BankAccountCommand(ba, BankAccountCommand.Action.WithDraw, 50); var composite = new CompositeBankAccountCommand(new[] { deposit, withdraw }); composite.Call(); Console.WriteLine(ba); composite.Undo(); Console.WriteLine(ba); }
public void Call_CreateAFewFailedCommandsAndCall_SetsCorrectBalance() { var ba = new BankAccount(); var commands = new List <BankAccountCommand>() { new BankAccountCommand(ba, BankAccountCommand.Action.Deposit, 100), new BankAccountCommand(ba, BankAccountCommand.Action.Withdraw, 20), new BankAccountCommand(ba, BankAccountCommand.Action.Withdraw, 1000) }; var composite = new CompositeBankAccountCommand(commands); composite.Call(); Assert.That(ba.Balance, Is.EqualTo(80)); }