Exemplo n.º 1
0
        public void Unexecute_DeleteItemInvoked()
        {
            // Arrange
            var paragrpahDocumentItem = new DocumentItem(new Paragraph.Paragraph(""));

            bool isDeleteItemInvoked = false;

            _documentMock.Setup(d => d.DeleteItem(It.IsAny <int>())).Callback(() => isDeleteItemInvoked = true);
            ICommand command = new InsertParagraphCommand("", _documentMock.Object, 1);

            // Act
            command.Unexecute();

            // Assert
            Assert.True(isDeleteItemInvoked);
        }
Exemplo n.º 2
0
        public void Unexecute_InsertParagraphCommand_WithEndPosition_ShouldInsertParagraph()
        {
            var previousParagraph = new TestParagraph();
            var documentItems     = new List <DocumentItem>()
            {
                new DocumentItem(previousParagraph)
            };
            var paragraph = new TestParagraph();
            var command   = new InsertParagraphCommand(documentItems, paragraph, null);

            command.Execute();
            Assert.AreEqual(paragraph, documentItems[1].Paragraph);

            command.Unexecute();
            Assert.AreEqual(previousParagraph, documentItems[0].Paragraph);
        }
        public void CanRemoveInsertedIfCallUnexecuteMethod()
        {
            var oldP  = new TestParagraph();
            var items = new List <DocumentItem>
            {
                new DocumentItem(new TestParagraph()),
                new DocumentItem(oldP),
            };

            var p = new TestParagraph();
            var c = new InsertParagraphCommand(items, p, 1);

            c.Execute();
            Assert.AreEqual(p, items[1].Paragraph);

            c.Unexecute();
            Assert.AreEqual(oldP, items[1].Paragraph);
        }