Expect action to fail Type of exception to expect Action to expect User custom message to display
(Type exceptionType, Action action, string message = "")
| 335 | /// <param name="action">Action to expect</param> |
| 336 | /// <param name="message">User custom message to display</param> |
| 337 | [Conditional("FLAX_ASSERTIONS")] |
| 338 | public static void ExceptionExpected(Type exceptionType, Action action, string message = "") |
| 339 | { |
| 340 | try |
| 341 | { |
| 342 | action(); |
| 343 | } |
| 344 | catch (Exception e) |
| 345 | { |
| 346 | if (exceptionType != e.GetType()) |
| 347 | { |
| 348 | Fail(GetMessage("Expected exception of type " + exceptionType.FullName + " got " + e.GetType().FullName), message); |
| 349 | } |
| 350 | return; |
| 351 | } |
| 352 | Fail(GetMessage("Expected exception of type " + exceptionType.FullName), message); |
| 353 | } |
| 354 | |
| 355 | public static string BooleanFailureMessage(bool expected) |
| 356 | { |