public void ExecuteWithExcludedExceptionConversion_NoExceptionThrown_RunsNormally()
        {
            int value = 0;

            Assert.AreEqual(0, value);
            ExcludingExceptionWrapper.ExecuteWithExcludedExceptionConversion(typeof(ArgumentException), () => value++);
            Assert.AreEqual(1, value);
        }
Exemplo n.º 2
0
        public ExpandCollapsePattern(A11yElement e, IUIAutomationExpandCollapsePattern p) : base(e, PatternType.UIA_ExpandCollapsePatternId)
        {
            // UIA sometimes throws a COMException. If it does, exclude it
            // from telemetry
            ExcludingExceptionWrapper.ExecuteWithExcludedExceptionConversion(typeof(COMException), () =>
            {
                Pattern = p;

                PopulateProperties();
            });
        }
Exemplo n.º 3
0
        public TextPattern(A11yElement e, IUIAutomationTextPattern p) : base(e, PatternType.UIA_TextPatternId)
        {
            // UIA sometimes throws a NotImplementedException. If it does, exclude it
            // from telemetry
            ExcludingExceptionWrapper.ExecuteWithExcludedExceptionConversion(typeof(NotImplementedException), () =>
            {
                Pattern = p;

                PopulateProperties();

                // if textPattern is supported , it means that user would do select text in the control.
                // so it should be marked as UI actionable
                IsUIActionable = true;
            });
        }
        public void ExecuteWithExcludedExceptionConversion_ExceptionThrownButTypeDoesNotMatch_ExcludesException()
        {
            const string expectedMessage = "blah";

            try
            {
                ExcludingExceptionWrapper.ExecuteWithExcludedExceptionConversion(typeof(ArgumentException), () => throw new ArgumentException(expectedMessage));
            }
            catch (Exception e)
            {
                Assert.AreEqual(expectedMessage, e.Message);
                Assert.AreEqual(expectedMessage, e.InnerException.Message);
                Assert.IsTrue(e.InnerException is ArgumentException);
                ExcludedException castException = e as ExcludedException;
                Assert.AreEqual(typeof(ArgumentException), castException.ExcludedType);
                throw;
            }
        }
        public void ExecuteWithExcludedExceptionConversion_ExceptionThrownAndTypeMatches_ExcludesException()
        {
            const string expectedMessage = "blah";

            ExcludingExceptionWrapper.ExecuteWithExcludedExceptionConversion(typeof(ArgumentException), () => throw new ArgumentNullException(expectedMessage));
        }