コード例 #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 IsValidTest()
        {
            //Arrange
            SwitchCommandMock mock = new SwitchCommandMock();

            //Act
            bool isValid = mock.IsValid();

            //Assert
            Assert.IsTrue(isValid);
        }
コード例 #3
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);
        }
コード例 #4
0
        public void ExecuteTest()
        {
            //Arrange
            bool hasInnerExecuted = false;

            SwitchCommandMock mock = new SwitchCommandMock();

            mock.OnInnerExecute += () =>
            {
                return(hasInnerExecuted = true);
            };

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

            //Assert
            Assert.IsTrue(executeResult);
            Assert.IsTrue(hasInnerExecuted);
        }
コード例 #5
0
        public void CommitTest()
        {
            //Arrange
            bool hasInnerCommitExecuted = false;

            SwitchCommandMock mock = new SwitchCommandMock();

            mock.OnInnerCommit += () =>
            {
                return(hasInnerCommitExecuted = true);
            };

            //Act
            bool commitResult = mock.Commit();

            //Assert
            Assert.IsTrue(hasInnerCommitExecuted);
            Assert.IsTrue(commitResult);
        }
コード例 #6
0
        public void DoubleCommitTest()
        {
            //Arrange
            int innerCommitCallCounter = 0;

            SwitchCommandMock mock = new SwitchCommandMock();

            mock.OnInnerCommit += () =>
            {
                innerCommitCallCounter++;
                return(true);
            };

            //Act
            bool firstCommitResult  = mock.Commit();
            bool secondCommitResult = mock.Commit();

            //Assert
            Assert.AreEqual(1, innerCommitCallCounter);
            Assert.IsTrue(firstCommitResult);
            Assert.IsFalse(secondCommitResult);
        }