Exemplo n.º 1
0
        public void SqlRetryTest_008()
        {
            var catchExceptionBeforeRetryCalled            = false;
            var catchExceptionAfterFinalRetryAttemptCalled = false;

            var tries = 0;

            Transient.SqlRetry(5, () =>
            {
                tries++;
                throw SqlExceptionHelper.Generate(SqlExceptionNumber.TimeoutExpired);
            }, (ex, i) =>
            {
                Assert.IsNotNull(ex);
                Assert.IsInstanceOfType(ex, typeof(SqlException));
                catchExceptionBeforeRetryCalled = true;
                return(true);
            }, (ex, i) =>
            {
                Assert.IsNotNull(ex);
                Assert.IsInstanceOfType(ex, typeof(SqlException));
                catchExceptionAfterFinalRetryAttemptCalled = true;
            });
            Assert.AreEqual(6, tries);
            Assert.IsTrue(catchExceptionBeforeRetryCalled);
            Assert.IsTrue(catchExceptionAfterFinalRetryAttemptCalled);
        }
Exemplo n.º 2
0
        public void SqlRetryTest_001()
        {
            var tries = 0;

            Transient.SqlRetry(() => {
                tries++;
            });
            Assert.AreEqual(1, tries);
        }
Exemplo n.º 3
0
        public void SqlRetryTest_005()
        {
            var tries = 0;

            Transient.SqlRetry(() =>
            {
                tries++;
                Assert.AreEqual(1, tries);
                throw new RetryTestException();
            });
        }
Exemplo n.º 4
0
        public void SqlRetryTest_004()
        {
            var tries = 0;

            Transient.SqlRetry(() =>
            {
                tries++;
                if (tries < 2)
                {
                    throw SqlExceptionHelper.Generate(SqlExceptionNumber.TransportLevelSending);
                }
            });
            Assert.AreEqual(2, tries);
        }
Exemplo n.º 5
0
        public void SqlRetryTest_002()
        {
            var tries = 0;

            Transient.SqlRetry(() =>
            {
                tries++;
                if (tries < 2)
                {
                    throw SqlExceptionHelper.Generate(SqlExceptionNumber.TimeoutExpired);
                }
            });
            Assert.AreEqual(2, tries);
        }
Exemplo n.º 6
0
        public void SqlRetryTest_006()
        {
            var tries = 0;

            Transient.SqlRetry(() =>
            {
                tries++;
                if (tries < 2)
                {
                    throw SqlExceptionHelper.Generate(500000);
                }
            });
            // only 1 is expected since it's not a Transient SqlException error number
            Assert.AreEqual(1, tries);
        }