Exemplo n.º 1
0
        public void ValidateTest()
        {
            //Act
            Quest        quest    = new FakeQuest();
            StubResponse response = new StubResponse();

            IQuestValidator <StubResponse> firstValidator = MockRepository.GenerateStrictMock <IQuestValidator <StubResponse> >();

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

            IQuestValidator <StubResponse> secondValidator = MockRepository.GenerateStrictMock <IQuestValidator <StubResponse> >();

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

            CompositeQuestValidator <StubResponse> validator = new CompositeQuestValidator <StubResponse>(new [] { firstValidator, secondValidator });

            //Arrange
            StubResponse returnedResponse = validator.Validate(quest);

            //Assert
            Assert.IsNotNull(returnedResponse);

            firstValidator.VerifyAllExpectations();
            secondValidator.VerifyAllExpectations();
        }
Exemplo n.º 2
0
        public void ValidateNullTest()
        {
            //Act
            CompositeQuestValidator <StubResponse> validator = new CompositeQuestValidator <StubResponse>(new IQuestValidator <StubResponse> [0]);

            //Arrange
            ArgumentNullException ex = Assert.Throws <ArgumentNullException>(() => validator.Validate(null));

            //Assert
            Assert.IsNotNull(ex);
            Assert.AreEqual("quest", ex.ParamName);
        }