public void ExecuteWithParentsOneReturnsFalseTest() { //Arrange Quest root = new FakeQuest(); Quest parent0 = new FakeQuest(); Quest parent1 = new FakeQuest(); Quest parent2 = new FakeQuest(); root.Parent = null; parent0.Parent = root; parent1.Parent = parent0; parent2.Parent = parent1; IQuestCommand innerCommand = MockRepository.GenerateStrictMock <IQuestCommand>(); innerCommand.Expect(ic => ic.Execute(Arg <Quest> .Is.Equal(parent2))).Repeat.Once().Return(true); innerCommand.Expect(ic => ic.Execute(Arg <Quest> .Is.Equal(parent1))).Repeat.Once().Return(false); innerCommand.Expect(ic => ic.Execute(Arg <Quest> .Is.Equal(parent0))).Repeat.Once().Return(true); innerCommand.Expect(ic => ic.Execute(Arg <Quest> .Is.Equal(root))).Repeat.Once().Return(true); UpHierarchyQuestCommandMock command = new UpHierarchyQuestCommandMock(parent2, innerCommand); //Act bool result = command.Execute(); //Assert Assert.IsTrue(result); innerCommand.VerifyAllExpectations(); }
public void IsValidTest() { //Arrange Quest quest = new FakeQuest(); IQuestCommand innerCommand = MockRepository.GenerateStrictMock <IQuestCommand>(); UpHierarchyQuestCommandMock command = new UpHierarchyQuestCommandMock(quest, innerCommand); //Act bool result = command.IsValid(); //Assert Assert.IsTrue(result); innerCommand.VerifyAllExpectations(); }
public void CommitTest() { //Arrange Quest quest = new FakeQuest(); IQuestCommand innerCommand = MockRepository.GenerateStrictMock <IQuestCommand>(); innerCommand.Expect(ic => ic.Commit()).Repeat.Once().Return(true); UpHierarchyQuestCommandMock command = new UpHierarchyQuestCommandMock(quest, innerCommand); //Act bool result = command.Commit(); //Assert Assert.IsTrue(result); innerCommand.VerifyAllExpectations(); }