예제 #1
0
        private static ErrorId GetRootErrorId(ICompositionError error)
        {
            Exception exception = error.InnerException;

            var childError = exception as ICompositionError;

            if (childError != null)
            {
                return(GetRootErrorId(childError));
            }

            CompositionException composition = exception as CompositionException;

            if (composition != null)
            {
                return(GetRootErrorId(composition));
            }

            return((ErrorId)error.Id);
        }
예제 #2
0
        private static void AssertCore(int retryCount, string prefix, ICompositionError error, CompositionErrorExpectation expectation)
        {
            if (expectation.IdSpecified)
            {
                AssertCore(retryCount, prefix, "Id", expectation.Id, (ErrorId)error.Id);
            }

            if (expectation.ElementSpecified)
            {
                AssertCore(retryCount, prefix, "Element", expectation.Element, error.Element);
            }

            if (expectation.InnerExceptionSpecified)
            {
                AssertCore(retryCount, prefix, "InnerException", expectation.InnerException, error.InnerException);
            }

            if (expectation.InnerExceptionTypeSpecified)
            {
                AssertCore(retryCount, prefix, "InnerException.GetType()", expectation.InnerExceptionType, error.InnerException == null ? null : error.InnerException.GetType());
            }

            if (expectation.InnerExpectationsSpecified)
            {
                ICompositionError innerError = error.InnerException as ICompositionError;
                if (innerError != null)
                {
                    Assert.AreEqual(1, expectation.InnerExpectations.Length);
                    AssertCore(retryCount, prefix + ".InnerException", innerError, expectation.InnerExpectations[0]);
                }
                else
                {
                    AssertCore(retryCount, prefix + ".InnerException", (CompositionException)error.InnerException, expectation.InnerExpectations);
                }
            }
        }