public void RejectMessagePattern()
            {
                Action fnFailAORException = () => OAssert.Throws <MyArgumentException>(ThrowException, NotMatchingPattern);
                Action fnFailArgException = () => OAssert.Throws <ArgumentException>(ThrowException, NotMatchingPattern);

                XAssert.Throws <ArgumentException>(fnFailAORException);
                XAssert.Throws <ArgumentException>(fnFailArgException);

                string expectedMessage = string.Format("Exception message '{0}' did not match expected pattern '{1}'", ExceptionMessage, NotMatchingPattern);

                try
                {
                    fnFailAORException();
                    throw new Exception("Action did not throw an exception!");
                }
                catch (Exception ex)
                {
                    XAssert.Equal(expectedMessage, ex.Message);
                }

                try
                {
                    fnFailArgException();
                    throw new Exception("Action did not throw an exception!");
                }
                catch (Exception ex)
                {
                    XAssert.Equal(expectedMessage, ex.Message);
                }
            }
            public void MatchMessagePattern()
            {
                // This should NOT throw an exception (Ockham.Assert.Throws passes)
                // Exact exception type and message
                OAssert.Throws <MyArgumentException>(ThrowException, ExceptionExactPattern);
                // Verifying we got this far
                XAssert.True(true);

                // This should NOT throw an exception (Ockham.Assert.Throws passes)
                // Exact exception type, pattern match
                OAssert.Throws <MyArgumentException>(ThrowException, ExceptionPattern);
                // Verifying we got this far
                XAssert.True(true);

                // This should NOT throw an exception (Ockham.Assert.Throws passes)
                // Parent exception type, exact message
                OAssert.Throws <ArgumentException>(ThrowException, ExceptionExactPattern);
                // Verifying we got this far
                XAssert.True(true);

                // This should NOT throw an exception (Ockham.Assert.Throws passes)
                // Parent exception type, pattern match
                OAssert.Throws <ArgumentException>(ThrowException, ExceptionPattern);
                // Verifying we got this far
                XAssert.True(true);
            }
            public void RejectNoException()
            {
                Action fnFailNoException = () => OAssert.Throws <DivideByZeroException>(() => { }, ExceptionExactPattern);

                XAssert.Throws <Exception>(fnFailNoException);

                string expectedMessage = "Action did not throw an exception";

                try
                {
                    fnFailNoException();
                    throw new Exception("Action did not throw an exception!");
                }
                catch (Exception ex)
                {
                    XAssert.Equal(expectedMessage, ex.Message);
                }
            }
            public void RejectWrongExType()
            {
                Action fnFailType = () => OAssert.Throws <DivideByZeroException>(ThrowException, ExceptionExactPattern);

                XAssert.Throws <Exception>(fnFailType);

                string expectedMessage = "Action threw exception of type " + typeof(MyArgumentException).Name + ", which does not inherit from expected exception type " + typeof(DivideByZeroException).Name;

                try
                {
                    fnFailType();
                    throw new Exception("Action did not throw an exception!");
                }
                catch (Exception ex)
                {
                    XAssert.Equal(expectedMessage, ex.Message);
                }
            }
            public void RejectInvalidRegex()
            {
                Action fnFailPattern = () => OAssert.Throws <Exception>(ThrowException, "^(");

                XAssert.Throws <ArgumentException>(fnFailPattern);

                string expectedMessage = "Error pattern '^(' is not valid regular expressions pattern";

                try
                {
                    fnFailPattern();
                    throw new Exception("Action did not throw an exception!");
                }
                catch (Exception ex)
                {
                    XAssert.Equal(expectedMessage, ex.Message);
                }
            }
            public void ExecuteTest()
            {
                bool closureCalled             = false;
                MyArgumentException exCaptured = null;

                Action <MyArgumentException> test = ex =>
                {
                    closureCalled = true;
                    exCaptured    = ex;
                };

                OAssert.Throws <MyArgumentException>(ThrowException, test);
                // Verifying we got this far
                XAssert.True(true);

                // Test that test was called:
                XAssert.True(closureCalled);
                XAssert.NotNull(exCaptured);
                XAssert.Equal(ExceptionMessage, exCaptured.Message);
            }
            public void RejectFailedTest()
            {
                bool closureCalled             = false;
                MyArgumentException exCaptured = null;

                Action <MyArgumentException> test = ex =>
                {
                    closureCalled = true;
                    exCaptured    = ex;
                    XAssert.Equal("no", ex.ActualValue);
                };

                Action fnFailTest = () => OAssert.Throws <MyArgumentException>(ThrowException, test);

                XAssert.Throws <Xunit.Sdk.EqualException>(fnFailTest);

                // Test that test was called:
                XAssert.True(closureCalled);
                XAssert.NotNull(exCaptured);
                XAssert.Equal(ExceptionMessage, exCaptured.Message);
            }
 public void RejectMissingAction()
 {
     XAssert.Throws <ArgumentNullException>(() => OAssert.Throws <Exception>(null, ""));
 }