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"); }