public void PastesGivenTextFromClipboardToTextEditor() { // Arrange var clipboard = new Clipboard(); var textArea = new TextArea(); var textEditor = new TextEditorApp(clipboard, textArea); Command cutCommand = new CutCommand(textArea, clipboard); textEditor.ExecuteCommand(cutCommand); Command pasteCommand = new PasteCommand(textArea, clipboard); // Act textEditor.ExecuteCommand(pasteCommand); // Assert Assert.Equal(" World!Hello", textArea.Value()); }
public void MultipleCommandExecution() { // Arrange var clipboard = new Clipboard(); var textArea = new TextArea(); var textEditor = new TextEditorApp(clipboard, textArea); // (Cut the 'Hello') Command cutCommand = new CutCommand(textArea, clipboard); textEditor.ExecuteCommand(cutCommand); Assert.Equal(" World!", textArea.Value()); Assert.Equal("Hello", clipboard.value); // (Copy the selected text; ' Worl') Command copyCommand = new CopyCommand(textArea, clipboard); textEditor.ExecuteCommand(copyCommand); Assert.Equal(" World!", textArea.Value()); Assert.Equal(" Worl", clipboard.value); // (Paste the ' Worl') Command pasteCommand = new PasteCommand(textArea, clipboard); textEditor.ExecuteCommand(pasteCommand); Assert.Equal(" World! Worl", textArea.Value()); // Act Command undoCommand = new UndoCommand(textArea, clipboard, textEditor); textEditor.ExecuteCommand(undoCommand); // Assert Assert.Equal(" World!", textArea.Value()); }