public void ExecuteOnQuestWithoutChildrenTest(bool beforeCommandResult)
        {
            //Arrange
            Quest         quest = QuestHelper.CreateQuest();
            IQuestCommand beforeQuestCommanduestCommand = MockRepository.GenerateStrictMock <IQuestCommand>();

            beforeQuestCommanduestCommand.Expect(bqc => bqc.Execute(Arg <Quest> .Is.Equal(quest)))
            .Repeat.Once()
            .Return(beforeCommandResult);

            IQuestCommand afterQuestCommand = MockRepository.GenerateStrictMock <IQuestCommand>();

            afterQuestCommand.Expect(aqc => aqc.Execute(Arg <Quest> .Is.Equal(quest)))
            .Repeat.Never();

            DownHierarchyQuestCommand command = new DownHierarchyQuestCommand(quest, beforeQuestCommanduestCommand,
                                                                              afterQuestCommand);

            //Act
            bool result = command.Execute();

            //Assert
            Assert.IsTrue(result);

            beforeQuestCommanduestCommand.VerifyAllExpectations();
            afterQuestCommand.VerifyAllExpectations();
        }
        public void CommitTestTest(bool beforeCommitResult, bool afterCommitResult)
        {
            //Arrange
            Quest quest = QuestHelper.CreateQuest();

            IQuestCommand beforeQuestCommanduestCommand = MockRepository.GenerateStrictMock <IQuestCommand>();

            beforeQuestCommanduestCommand.Expect(bqc => bqc.Commit()).
            Repeat.Once().
            Return(beforeCommitResult);

            IQuestCommand afterQuestCommand = MockRepository.GenerateStrictMock <IQuestCommand>();

            afterQuestCommand.Expect(aqc => aqc.Commit()).
            Repeat.Once().
            Return(afterCommitResult);

            DownHierarchyQuestCommand command = new DownHierarchyQuestCommand(quest, beforeQuestCommanduestCommand,
                                                                              afterQuestCommand);

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

            //Assert
            Assert.AreEqual(beforeCommitResult && afterCommitResult, result);

            beforeQuestCommanduestCommand.VerifyAllExpectations();
            afterQuestCommand.VerifyAllExpectations();
        }
        public void UndoOnQuestWithChildrenTest(bool beforeCommandResult)
        {
            //Arrange
            Quest child = QuestHelper.CreateQuest();
            Quest quest = QuestHelper.CreateQuest();

            quest.Children = new List <Quest> {
                child
            };

            IQuestCommand beforeQuestCommanduestCommand = MockRepository.GenerateStrictMock <IQuestCommand>();

            beforeQuestCommanduestCommand.Expect(bqc => bqc.Undo(Arg <Quest> .Is.Equal(quest)))
            .Repeat.Once()
            .Return(beforeCommandResult);
            if (beforeCommandResult)
            {
                beforeQuestCommanduestCommand.Expect(bqc => bqc.Undo(Arg <Quest> .Is.Equal(child)))
                .Repeat.Once()
                .Return(true);
            }

            IQuestCommand afterQuestCommand = MockRepository.GenerateStrictMock <IQuestCommand>();

            if (beforeCommandResult)
            {
                afterQuestCommand.Expect(aqc => aqc.Undo(Arg <Quest> .Is.Equal(quest)))
                .Repeat.Once()
                .Return(true);
            }

            DownHierarchyQuestCommand command = new DownHierarchyQuestCommand(quest, beforeQuestCommanduestCommand,
                                                                              afterQuestCommand);

            //Act
            bool result = command.Undo();

            //Assert
            Assert.IsTrue(result);

            beforeQuestCommanduestCommand.VerifyAllExpectations();
            afterQuestCommand.VerifyAllExpectations();
        }
        public void IsValidTest()
        {
            //Arrange
            Quest quest = QuestHelper.CreateQuest();

            IQuestCommand beforeQuestCommanduestCommand = MockRepository.GenerateStrictMock <IQuestCommand>();
            IQuestCommand afterQuestCommand             = MockRepository.GenerateStrictMock <IQuestCommand>();

            DownHierarchyQuestCommand command = new DownHierarchyQuestCommand(quest, beforeQuestCommanduestCommand,
                                                                              afterQuestCommand);

            //Act
            bool result = command.IsValid();

            //Assert
            Assert.IsTrue(result);

            beforeQuestCommanduestCommand.VerifyAllExpectations();
            afterQuestCommand.VerifyAllExpectations();
        }