Ejemplo n.º 1
0
        public void InitializeTest()
        {
            //Arrange
            IQuestViewModel questViewModel = MockRepository.GenerateStrictMock <IQuestViewModel>();

            IQuestViewModelFactory vmFactory = MockRepository.GenerateStrictMock <IQuestViewModelFactory>();

            vmFactory.Expect(vmf => vmf.CreateQuestViewModel()).
            Repeat.Once().
            Return(questViewModel);

            IQuestValidator <ClarifiedResponse <int> > validator =
                MockRepository.GenerateStrictMock <IQuestValidator <ClarifiedResponse <int> > >();

            MockQuestAbstractActionViewModel viewModel = new MockQuestAbstractActionViewModel(vmFactory, validator);

            //Act
            viewModel.Initialize();

            //Assert
            Assert.AreEqual(questViewModel, viewModel.QuestViewModel);

            questViewModel.VerifyAllExpectations();
            validator.VerifyAllExpectations();
        }
Ejemplo n.º 2
0
        public void ValidateTest()
        {
            //Arrange
            Quest model = new FakeQuest();
            ClarifiedResponse <int> response = new ClarifiedResponse <int>();

            IQuestViewModel questViewModel = MockRepository.GenerateStrictMock <IQuestViewModel>();

            questViewModel.Expect(qvm => qvm.Model).
            Repeat.Once().
            Return(model);

            IQuestViewModelFactory vmFactory = MockRepository.GenerateStrictMock <IQuestViewModelFactory>();

            vmFactory.Expect(vmf => vmf.CreateQuestViewModel()).
            Repeat.Once().
            Return(questViewModel);

            IQuestValidator <ClarifiedResponse <int> > validator =
                MockRepository.GenerateStrictMock <IQuestValidator <ClarifiedResponse <int> > >();

            validator.Expect(v => v.Validate(Arg <Quest> .Is.Equal(model))).
            Repeat.Once().
            Return(response);

            MockQuestAbstractActionViewModel viewModel = new MockQuestAbstractActionViewModel(vmFactory, validator);

            //Act
            viewModel.Initialize();
            ClarifiedResponse <int> actualResponse = viewModel.Validate();

            //Assert
            Assert.IsNotNull(actualResponse);
            Assert.AreEqual(response, actualResponse);

            questViewModel.VerifyAllExpectations();
            vmFactory.VerifyAllExpectations();
            validator.VerifyAllExpectations();
        }