@@ -21,15 +21,34 @@ public SuccessException(string message, Exception innerException) : base(message
2121 }
2222 }
2323
24+ /// <summary>
25+ /// Exception thrown when an assertion fails
26+ /// </summary>
27+ /// <seealso cref="System.Exception" />
28+ public class AssertException : Exception
29+ {
30+ public AssertException ( )
31+ {
32+ }
33+
34+ public AssertException ( string message ) : base ( message )
35+ {
36+ }
37+
38+ public AssertException ( string message , Exception innerException ) : base ( message , innerException )
39+ {
40+ }
41+ }
42+
2443 public static class Assert
2544 {
2645 public static void Pass ( ) => throw new SuccessException ( ) ;
27- public static void Fail ( ) => throw new Exception ( ) ;
46+ public static void Fail ( ) => throw new AssertException ( "Fail" ) ;
2847
29- public static void AreEqual ( object a , object b ) { if ( ! Equals ( a , b ) ) throw new Exception ( ) ; }
30- public static void AreNotEqual ( object a , object b ) { if ( Equals ( a , b ) ) throw new Exception ( ) ; }
48+ public static void AreEqual ( object a , object b ) { if ( ! Equals ( a , b ) ) throw new AssertException ( $ " { a } does not equal { b } " ) ; }
49+ public static void AreNotEqual ( object a , object b ) { if ( Equals ( a , b ) ) throw new Exception ( $ " { a } is equal to { b } " ) ; }
3150
32- public static void True ( bool a ) { if ( ! a ) throw new Exception ( ) ; }
33- public static void False ( bool a ) { if ( a ) throw new Exception ( ) ; }
51+ public static void True ( bool a ) { if ( ! a ) throw new Exception ( $ " { a } is not true" ) ; }
52+ public static void False ( bool a ) { if ( a ) throw new Exception ( $ " { a } is not false" ) ; }
3453 }
3554}
0 commit comments