Beispiel #1
0
        public void UndoAfterExecutionTest()
        {
            //Arrange
            IQuestTree repository = MockRepository.GenerateStrictMock <IQuestTree>();

            Quest parent   = new Quest();
            Quest toDelete = new Quest();

            repository.Expect(rep => rep.RemoveChild(Arg <Quest> .Is.Equal(parent), Arg <Quest> .Is.Equal(toDelete))).
            Repeat.Once();
            repository.Expect(rep => rep.AddChild(Arg <Quest> .Is.Equal(parent), Arg <Quest> .Is.Equal(toDelete))).Repeat.Once();

            ICommand command = new DeleteQuestCommand(repository, parent, toDelete);

            //Act
            command.Execute();
            command.Undo();

            //Assert
            repository.VerifyAllExpectations();
        }
Beispiel #2
0
        public void ExecuteTest()
        {
            //Arrange
            IQuestTree repository = MockRepository.GenerateStrictMock <IQuestTree>();

            Quest parent   = QuestHelper.CreateQuest();
            Quest toDelete = QuestHelper.CreateQuest(42);

            repository.Expect(rep => rep.RemoveChild(Arg <Quest> .Is.Equal(parent), Arg <Quest> .Is.Equal(toDelete))).
            Repeat.Once();

            ICommand command = new DeleteQuestCommand(repository, parent, toDelete);

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

            //Assert
            Assert.IsTrue(result);

            repository.VerifyAllExpectations();
        }