public void Reactive_policy_should_be_able_to_ignore_unhandled_result() { ResultPrimitive?handled = null; AddBehaviourIfHandlePolicy <ResultPrimitive> policy = Policy.HandleResult <ResultPrimitive>(ResultPrimitive.Fault).WithBehaviour(outcome => handled = outcome.Result); ResultPrimitive toReturn = ResultPrimitive.FaultYetAgain; bool executed = false; policy.Execute(() => { executed = true; return(toReturn); }) .Should().Be(toReturn); executed.Should().BeTrue(); handled.Should().Be(null); }
public void Reactive_policy_should_handle_result() { ResultPrimitive handled = ResultPrimitive.Undefined; AddBehaviourIfHandlePolicy <ResultPrimitive> policy = Policy.HandleResult <ResultPrimitive>(ResultPrimitive.Fault).WithBehaviour(outcome => handled = outcome.Result); ResultPrimitive toReturn = ResultPrimitive.Fault; bool executed = false; policy.Execute(() => { executed = true; return(toReturn); }) .Should().Be(toReturn); executed.Should().BeTrue(); handled.Should().Be(toReturn); }