Пример #1
0
        public void UndoAfterExecuteCommitTest()
        {
            //Arrange
            bool hasInnerExecute = false;
            bool hasInnerUndo    = false;

            SwitchCommandMock mock = new SwitchCommandMock();

            mock.OnInnerExecute += () =>
            {
                return(hasInnerExecute = true);
            };
            mock.OnInnerUndo += () =>
            {
                return(hasInnerUndo = true);
            };

            //Act
            bool executeResult = mock.Execute();

            mock.Commit();
            bool undoResult = mock.Undo();

            //Assert
            Assert.IsTrue(executeResult);
            Assert.IsFalse(undoResult);
            Assert.IsTrue(hasInnerExecute);
            Assert.IsFalse(hasInnerUndo);
        }
Пример #2
0
        public void UndoWithoutExecuteTest()
        {
            //Arrange
            bool hasInnerUndo = false;

            SwitchCommandMock mock = new SwitchCommandMock();

            mock.OnInnerUndo += () =>
            {
                return(hasInnerUndo = true);
            };

            //Act
            bool undoResult = mock.Undo();

            //Assert
            Assert.IsFalse(undoResult);
            Assert.IsFalse(hasInnerUndo);
        }