예제 #1
0
        public void Should_call_onretry_with_the_passed_context_when_execute_and_capture()
        {
            IDictionary <string, object> contextData = null;

            ContextualPolicy policy = Policy
                                      .Handle <DivideByZeroException>()
                                      .RetryAsync((_, __, context) => contextData = context);

            policy.Awaiting(p => p.ExecuteAndCaptureAsync(() => { throw new DivideByZeroException(); },
                                                          new { key1 = "value1", key2 = "value2" }.AsDictionary()))
            .ShouldNotThrow();

            contextData.Should()
            .ContainKeys("key1", "key2").And
            .ContainValues("value1", "value2");
        }