Beispiel #1
0
 private void AssertRetryHandling(ErrorMessageHandler handler, SifMessagePayload payload, ZoneImpl zone)
 {
     try
     {
         assertNormalHandling(handler, payload, zone);
     }
     catch (SifException ex)
     {
         Assert.IsTrue(handler.wasCalled(), "Handler was not called");
         Assert.AreEqual(SifErrorCategoryCode.Transport, ex.ErrorCategory,
                         "SIF Error category should be 10: " + ex.Message);
     }
     Assert.IsTrue(handler.wasCalled(), "Handler was not called");
     AssertThreadIsOK();
 }
Beispiel #2
0
        private void assertNormalHandling(ErrorMessageHandler handler, SifMessagePayload payload, ZoneImpl zone)
        {
            MessageDispatcher testDispatcher = new MessageDispatcher(zone);
            int result = testDispatcher.dispatch(payload);

            Assert.IsTrue(handler.wasCalled(), "Handler was not called");
            Assert.AreEqual(1, result, "Result code should always be 1 because this version does not support SMB");
        }
Beispiel #3
0
        private void AssertExceptionHandling(ErrorMessageHandler handler, SifMessagePayload payload, ZoneImpl zone,
                                             Type expectedExceptionType)
        {
            Exception exc = null;

            try
            {
                assertNormalHandling(handler, payload, zone);
            }
            catch (Exception ex)
            {
                exc = ex;
                Assert.IsTrue(handler.wasCalled(), "Handler was not called");

                AdkMessagingException adkme = ex as AdkMessagingException;
                Assert.IsNotNull(adkme,
                                 "Expected an ADKMessagingException, but was " + ex.GetType().Name + ":" + ex.ToString());

                Exception source  = adkme;
                Exception innerEx = null;
                while (source.InnerException != null)
                {
                    innerEx = source.InnerException;
                    source  = innerEx;
                }
                Assert.IsNotNull(innerEx, "AdkMessaginException was thrown but inner exception was not set");

                if (innerEx.GetType() != expectedExceptionType)
                {
                    Assert.Fail("Exception thrown was not a " + expectedExceptionType.Name + ", but was " +
                                innerEx.GetType().Name + ":" + innerEx.ToString());
                }
            }

            Assert.IsNotNull(exc, "An exception was not thrown by the handler");
            AssertThreadIsOK();
        }