Exemplo n.º 1
0
        private void RunMethodTest()
        {
            SimpleTest test = TestDelegate;

            if (ExpectedExceptionType == null)
            {
                test();
            }
            // otherwise some sort of exception is expected
            else
            {
                try
                {
                    test();
                }
                catch (Exception e)
                {
                    if (ExpectedExceptionType == e.GetType())
                    {
                        // TODO: Bug 736396
                        //if((ExpectedInnerExceptionType == null && e.InnerException == null) || (ExpectedInnerExceptionType == e.InnerException.GetType()))
                        return;
                    }
                    throw new InvalidOperationException("Wrong Exception was thrown", e);
                }
                throw new InvalidOperationException(String.Format("Expected exception {0} was not thrown", ExpectedExceptionType.ToString()));
            }
        }
Exemplo n.º 2
0
        private void RunStringTest()
        {
            // If it is a String Test then load the string.
            string            xamlString = XamlString;
            XamlStringParser  loader     = StringParserDelegate;
            PostTreeValidator validator  = TreeValidatorDelegate;

            if (ExpectedExceptionType == null)
            {
                LoadAndValidate(loader, xamlString, validator);
            }
            // otherwise some sort of exception is expected
            else
            {
                try
                {
                    LoadAndValidate(loader, xamlString, validator);
                }
                catch (Exception e)
                {
                    if (ExpectedExceptionType == e.GetType())
                    {
                        if ((ExpectedInnerExceptionType == null && e.InnerException == null) || (ExpectedInnerExceptionType == e.InnerException.GetType()))
                        {
                            return;
                        }
                    }
                    throw new InvalidOperationException("Wrong Exception was thrown", e);
                }
                throw new InvalidOperationException(String.Format("Expected exception {0} was not thrown", ExpectedExceptionType.ToString()));
            }
        }