Example #1
0
        public void IfOneOrMoreCommitWithFalseResultFalseTest(bool[] commitResults)
        {
            //Arrange
            int count = commitResults.Length;

            ICommand[] commands = new ICommand[count];
            for (int i = 0; i < count; ++i)
            {
                commands[i] = MockRepository.GenerateStrictMock <ICommand>();
                commands[i].Expect(cm => cm.Commit()).
                Return(commitResults[i]).
                Repeat.Once();
                if (!commitResults[i])
                {
                    break;
                }
            }

            ICommand composite = new CompositeCommand(commands);

            //Act
            bool result = composite.Commit();

            //Assert
            Assert.IsFalse(result);

            foreach (ICommand command in commands)
            {
                command?.VerifyAllExpectations();
            }
        }
Example #2
0
        public void CommitTest()
        {
            //Arrange
            ICommand[] commands = CreateCommands(5, (cm) =>
            {
                cm.Expect(c => c.Commit()).Repeat.Once().Return(true);
            });

            CompositeCommand compositeCommand = new CompositeCommand(commands);

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

            //Assert
            Assert.IsTrue(commitResult);

            foreach (ICommand command in commands)
            {
                command.VerifyAllExpectations();
            }
        }