예제 #1
0
        public void ShouldReturnSuccessfulResultIfConditionIsApplicable()
        {
            var rule = new Rule(Dummy.Condition(true), Dummy.GenerateNextRequest(), Dummy.CreateNextState());
            var result = rule.Evaluate(Dummy.PreviousResponse, Dummy.StateVariables, Dummy.ClientCapabilities);

            Assert.IsTrue(result.IsSuccessful);
        }
예제 #2
0
        public void ShouldCreateNewStateIfActionIsSuccessful()
        {
            var rule = new Rule(Dummy.Condition(true), Dummy.GenerateNextRequest(), Dummy.CreateNextState());
            var result = rule.Evaluate(Dummy.PreviousResponse, Dummy.StateVariables, Dummy.ClientCapabilities);

            Assert.AreEqual(Dummy.NewState, result.State);
        }
예제 #3
0
        public void ShouldNotExecuteActionIfConditionIsNotApplicable()
        {
            var mockGenerateNextRequest = MockRepository.GenerateMock<IRequestAction>();
            mockGenerateNextRequest.AssertWasNotCalled(a => a.Execute(Dummy.PreviousResponse, Dummy.StateVariables, Dummy.ClientCapabilities));

            var rule = new Rule(Dummy.Condition(false), mockGenerateNextRequest, Dummy.CreateNextState());
            rule.Evaluate(Dummy.PreviousResponse, Dummy.StateVariables, Dummy.ClientCapabilities);

            mockGenerateNextRequest.VerifyAllExpectations();
        }
예제 #4
0
        public void ShouldExecuteActionIfConditionIsApplicable()
        {
            var mockGenerateNextRequest = MockRepository.GenerateMock<IRequestAction>();
            mockGenerateNextRequest.Expect(a => a.Execute(Dummy.PreviousResponse, Dummy.StateVariables, Dummy.ClientCapabilities)).Return(Dummy.NewResponse);

            var rule = new Rule(Dummy.Condition(true), mockGenerateNextRequest, Dummy.CreateNextState());
            rule.Evaluate(Dummy.PreviousResponse, Dummy.StateVariables, Dummy.ClientCapabilities);

            mockGenerateNextRequest.VerifyAllExpectations();
        }