コード例 #1
0
        public void UndoShouldExecuteTheReverseCommand()
        {
            var command        = Substitute.For <ICommand>();
            var reverseCommand = Substitute.For <ICommand>();

            command.GetReverseCommand().Returns(reverseCommand);

            var outline = new Outline();
            var co      = new CommandOutline(outline);

            co.RunCommand(command);
            co.Undo();
            reverseCommand.Received(1).Do(outline);
        }
コード例 #2
0
        public void NewCommandShouldClearRedos()
        {
            var command               = Substitute.For <ICommand>();
            var reverseCommand        = Substitute.For <ICommand>();
            var reverseReverseCommand = Substitute.For <ICommand>();

            command.GetReverseCommand().Returns(reverseCommand);
            reverseCommand.GetReverseCommand().Returns(reverseReverseCommand);

            var outline = new Outline();
            var co      = new CommandOutline(outline);

            co.RunCommand(command);
            co.Undo();
            co.RunCommand(Substitute.For <ICommand>());
            co.Redo();
            reverseReverseCommand.Received(0).Do(outline);
        }