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); }
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); }
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(); }
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(); }