public void TestUndoRedoCommand() { // Arrange ProjectBlockCollection blocks; BlockCommandSupervisor commands; BlockTypeSupervisor blockTypes; BlockCommandContext context; SetupMultilineTest(out context, out blocks, out blockTypes, out commands); var command = new DeleteMultilineTextCommand( blocks, new BlockPosition(blocks[0].BlockKey, 5), new BlockPosition(blocks[3].BlockKey, 5)); commands.Do(command, context); commands.Undo(context); // Act commands.Redo(context); // Assert Assert.AreEqual(1, blocks.Count); Assert.AreEqual(new BlockPosition(blocks[0], 5), commands.LastPosition); const int index = 0; Assert.AreEqual("Line 4", blocks[index].Text); Assert.AreEqual(blockTypes.Chapter, blocks[index].BlockType); }
public void TestUndoCommand() { // Arrange ProjectBlockCollection blocks; BlockCommandSupervisor commands; BlockTypeSupervisor blockTypes; BlockCommandContext context; SetupMultilineTest(out context, out blocks, out blockTypes, out commands); var command = new DeleteMultilineTextCommand( blocks, new BlockPosition(blocks[0].BlockKey, 5), new BlockPosition(blocks[3].BlockKey, 5)); commands.Do(command, context); // Act commands.Undo(context); // Assert Assert.AreEqual(4, blocks.Count); Assert.AreEqual(new BlockPosition(blocks[3], 5), commands.LastPosition); int index = 0; Assert.AreEqual("Line 1", blocks[index].Text); Assert.AreEqual(blockTypes.Chapter, blocks[index].BlockType); index++; Assert.AreEqual("Line 2", blocks[index].Text); Assert.AreEqual(blockTypes.Scene, blocks[index].BlockType); index++; Assert.AreEqual("Line 3", blocks[index].Text); Assert.AreEqual(blockTypes.Scene, blocks[index].BlockType); index++; Assert.AreEqual("Line 4", blocks[index].Text); Assert.AreEqual(blockTypes.Scene, blocks[index].BlockType); }