Inheritance: AsyncCompletedEventArgs
 public static void CtorTest(Exception expectedException, bool expectedCancelled, object expectedState)
 {
     var target = new AsyncCompletedEventArgsTests(expectedException, expectedCancelled, expectedState);
     Assert.Equal(expectedException, target.Error);
     Assert.Equal(expectedCancelled, target.Cancelled);
     Assert.Equal(expectedState, target.UserState);
 }
        public static void CtorTest(Exception expectedException, bool expectedCancelled, object expectedState)
        {
            var target = new AsyncCompletedEventArgsTests(expectedException, expectedCancelled, expectedState);

            Assert.Equal(expectedException, target.Error);
            Assert.Equal(expectedCancelled, target.Cancelled);
            Assert.Equal(expectedState, target.UserState);
        }
        public static void RaiseExceptionIfNecessaryTest(Exception expectedError, bool cancelled, Type expectedExceptionType)
        {
            var target = new AsyncCompletedEventArgsTests(expectedError, cancelled, null);

            if (expectedExceptionType == null) // if null should NOT throw
            {
                target.RaiseExceptionIfNecessary();
            }
            else
            {
                Exception error = Assert.Throws(expectedExceptionType, () => target.RaiseExceptionIfNecessary());
                if (expectedError != null && !cancelled)
                {
                    Assert.Same(expectedError, error);
                }
            }
        }
        public static void RaiseExceptionIfNecessaryTest(Exception expectedError, bool cancelled, Type expectedExceptionType)
        {
            var target = new AsyncCompletedEventArgsTests(expectedError, cancelled, null);

            if (expectedExceptionType == null) // if null should NOT throw
            {
                target.RaiseExceptionIfNecessary();
            }
            else
            {
                Exception error = Assert.Throws(expectedExceptionType, () => target.RaiseExceptionIfNecessary());
                if (expectedError != null && !cancelled)
                {
                    Assert.Same(expectedError, error);
                }
            }
        }
        public static void RaiseExceptionIfNecessaryTest(Exception expectedError, bool cancelled, Type expectedExceptionType)
        {
            var target = new AsyncCompletedEventArgsTests(expectedError, cancelled, null);

            if (expectedExceptionType == null) // if null should NOT throw
            {
                target.RaiseExceptionIfNecessary();
            }
            else
            {
                if (expectedError != null)
                {
                    TargetInvocationException error = Assert.Throws <TargetInvocationException>(() => target.RaiseExceptionIfNecessary());
                    Assert.Equal(expectedExceptionType, error.InnerException.GetType());
                    Assert.Same(expectedError, error.InnerException);
                }
                else if (cancelled)
                {
                    Assert.Throws(expectedExceptionType, () => target.RaiseExceptionIfNecessary());
                }
            }
        }
        public static void RaiseExceptionIfNecessaryTest(Exception expectedError, bool cancelled, Type expectedExceptionType)
        {
            var target = new AsyncCompletedEventArgsTests(expectedError, cancelled, null);

            if (expectedExceptionType == null) // if null should NOT throw
            {
                target.RaiseExceptionIfNecessary();
            }
            else
            {
                if (expectedError != null)
                {
                    TargetInvocationException error = Assert.Throws<TargetInvocationException>(() => target.RaiseExceptionIfNecessary());
                    Assert.Equal(expectedExceptionType, error.InnerException.GetType());
                    Assert.Same(expectedError, error.InnerException);
                }
                else if (cancelled)
                {
                    Assert.Throws(expectedExceptionType, () => target.RaiseExceptionIfNecessary());
                }
            }
        }