public void CanReturnTextBackToPreviousState()
        {
            var    i       = new TestReplacable();
            string oldText = "test";

            i.Text = oldText;
            string str = "sth";
            var    c   = new ReplaceTextCommand(i, str);

            c.Execute();
            Assert.AreEqual(i.Text, str);
            c.Unexecute();
            Assert.AreEqual(i.Text, oldText);
        }
Example #2
0
        public void Unexecute_ReturnOriginTextValue()
        {
            // Arrange
            var paragrpahDocumentItem = new DocumentItem(new Paragraph.Paragraph(""));

            _documentMock.Setup(d => d.GetItem(It.IsAny <int>())).Returns(paragrpahDocumentItem);
            ICommand command = new ReplaceTextCommand(1, "Hey", _documentMock.Object);

            command.Execute();

            // Act
            command.Unexecute();

            // Assert
            Assert.Equal("", paragrpahDocumentItem.Paragraph.Text);
        }
Example #3
0
        public void Unexecute_ReplaceTextCommand_ShouldReturnPrevTextToParagraph()
        {
            var prevText  = "Old text";
            var paragraph = new Text()
            {
                Value = prevText
            };
            var newText = "New text";
            var command = new ReplaceTextCommand(paragraph, newText);

            command.Execute();
            Assert.AreEqual(newText, paragraph.Value);

            command.Unexecute();
            Assert.AreEqual(prevText, paragraph.Value);
        }