Executes IUndoCommands and collects them into a CompositeCommand allowing a combined undo later on.
Inheritance: ICommandExecutor
Ejemplo n.º 1
0
        public void Test()
        {
            var collector = new CommandCollector();

            var command1 = new MockCommand();
            collector.Execute(command1);
            command1.Executed.Should().BeTrue(because: "Should execute while collecting");
            var command2 = new MockCommand();
            collector.Execute(command2);
            command2.Executed.Should().BeTrue(because: "Should execute while collecting");

            var composite = collector.BuildComposite();
            composite.Execute();
            composite.Undo();
            command1.Executed.Should().BeFalse(because: "Should undo as part of composite");
            // ReSharper disable once HeuristicUnreachableCode
            command2.Executed.Should().BeFalse(because: "Should undo as part of composite");
        }
Ejemplo n.º 2
0
        public void Test()
        {
            var collector = new CommandCollector();

            var command1 = new MockCommand();

            collector.Execute(command1);
            command1.Executed.Should().BeTrue(because: "Should execute while collecting");
            var command2 = new MockCommand();

            collector.Execute(command2);
            command2.Executed.Should().BeTrue(because: "Should execute while collecting");

            var composite = collector.BuildComposite();

            composite.Execute();
            composite.Undo();
            command1.Executed.Should().BeFalse(because: "Should undo as part of composite");
            // ReSharper disable once HeuristicUnreachableCode
            command2.Executed.Should().BeFalse(because: "Should undo as part of composite");
        }