示例#1
0
        public static Exception Throws(Type type, AssertThrowsItemWhichReturnsVoid methodWhichReturnsVoid)
        {
            try
            {
                methodWhichReturnsVoid();
            }
            catch(Exception ex)
            {
                if(ex.GetType() != type)
                {
                    Fail("Expected exception of type '" + type.FullName + "' however '" + ex.GetType().FullName + "' was thrown.");
                }

                return ex;
            }

            Fail("Expected exception of type '" + type.FullName + "'.");

            throw new InvalidOperationException("Code should have failed by this point.");
        }
示例#2
0
        public static Exception Throws(Type type, AssertThrowsItemWhichReturnsVoid methodWhichReturnsVoid)
        {
            try
            {
                methodWhichReturnsVoid();
            }
            catch (Exception ex)
            {
                if (ex.GetType() != type)
                {
                    Fail("Expected exception of type '" + type.FullName + "' however '" + ex.GetType().FullName + "' was thrown.");
                }

                return(ex);
            }

            Fail("Expected exception of type '" + type.FullName + "'.");

            throw new InvalidOperationException("Code should have failed by this point.");
        }