コード例 #1
0
        public void CopiesGivenTextToClipboard()
        {
            // Arrange
            var     clipboard   = new Clipboard();
            var     textArea    = new TextArea();
            var     textEditor  = new TextEditorApp(clipboard, textArea);
            Command copyCommand = new CopyCommand(textArea, clipboard);

            // Act
            textEditor.ExecuteCommand(copyCommand);

            // Assert
            Assert.Equal("Hello", textEditor.ClipboardValue());
        }
コード例 #2
0
        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());
        }