public void Evaluate_WhenNotMatchedAndAlternatePolicyDoesntExist_ShouldReturnFalse() { var sut = new RestResponseHandlerPolicy(_mockRestResponse, (restResponse => false), restResponse => {}); var handled = sut.Evaluate(); Assert.IsFalse(handled); }
public void Evaluate_WhenNotMatchedAndAlteratePolicyExists_ShouldCallAlternatePolicy() { int result = 0; var sut = new RestResponseHandlerPolicy(_mockRestResponse, (restResponse => false), restResponse => { result = 1; }); var alternatePolicy = new RestResponseHandlerPolicy(_mockRestResponse, (restResponse => true), restResponse => { result = 2; }); sut.Next(alternatePolicy); var handled = sut.Evaluate(); Assert.IsTrue(handled); Assert.AreEqual(2, result); }
public void Evaluate_WhenMatched_ShouldNotCallAlternatePolicy() { IRestResponse response = Mock.Of <IRestResponse>(); int result = 0; var sut = new RestResponseHandlerPolicy(_mockRestResponse, (restResponse => true), restResponse => { result = 1; }); var alternatePolicy = new RestResponseHandlerPolicy(_mockRestResponse, (restResponse => true), restResponse => { result = 2; }); var handled = sut.Evaluate(); sut.Next(alternatePolicy); Assert.IsTrue(handled); Assert.AreEqual(1, result); }