Ejemplo n.º 1
0
        public void Func_With_1_Args_InvokeWithNoRetry()
        {
            // arrange
            Operations operations = new Operations(0);

            var policy = Policy.NoRetry();
            var func = operations.GetFunc<int, int>();

            // act
            func.InvokeWithRetry(policy.RetryPolicy, 0);

            // assert
            Assert.Equal(0, policy.ShouldRetryCallCount);
            Assert.Equal(0, operations.ThrowCount);
            Assert.Equal(1, operations.ExecuteCount);
        }
Ejemplo n.º 2
0
        public void Func_will_throw_when_policy_returns_false()
        {
            // arrange
            Operations operations = new Operations(1);

            var policy = Policy.NoRetry();
            var func = operations.GetFunc<int>();

            Assert.ThrowsDelegate testCode = () => func.InvokeWithRetry(policy.RetryPolicy);

            // act
            Exception exception = Assert.Throws<Exception>(testCode);

            // assert
            Assert.Equal(1, policy.ShouldRetryCallCount);
            Assert.Equal(string.Format(Operations.ExceptionMessageFormat, 1), exception.Message);
            Assert.Equal(1, operations.ThrowCount);
            Assert.Equal(1, operations.ExecuteCount);
        }
Ejemplo n.º 3
0
        public void Func_With_9_Args_InvokeWithNoRetry()
        {
            // arrange
            Operations operations = new Operations(0);

            var func = operations.GetFunc<int,int,int,int,int,int,int,int,int,int>();

            // act
            func.InvokeWithRetry(RetryPolicies.NoRetry(),0,0,0,0,0,0,0,0,0);

            // assert
            Assert.Equal(0, operations.ThrowCount);
            Assert.Equal(1, operations.ExecuteCount);
        }