Rev | Line | |
---|
[12503] | 1 | using System;
|
---|
| 2 | using System.Collections.Generic;
|
---|
| 3 | using System.Linq;
|
---|
| 4 | using System.Text;
|
---|
| 5 | using System.Diagnostics;
|
---|
| 6 |
|
---|
| 7 | namespace Microsoft.Research.DynamicDataDisplay.Common.Auxiliary
|
---|
| 8 | {
|
---|
| 9 | internal static class Verify
|
---|
| 10 | {
|
---|
| 11 | [DebuggerStepThrough]
|
---|
| 12 | public static void IsTrue(this bool condition)
|
---|
| 13 | {
|
---|
| 14 | if (!condition)
|
---|
| 15 | {
|
---|
| 16 | throw new ArgumentException(Strings.Exceptions.AssertionFailedSearch);
|
---|
| 17 | }
|
---|
| 18 | }
|
---|
| 19 |
|
---|
| 20 | [DebuggerStepThrough]
|
---|
| 21 | public static void IsTrue(this bool condition, string paramName)
|
---|
| 22 | {
|
---|
| 23 | if (!condition)
|
---|
| 24 | {
|
---|
| 25 | throw new ArgumentException(Strings.Exceptions.AssertionFailedSearch, paramName);
|
---|
| 26 | }
|
---|
| 27 | }
|
---|
| 28 |
|
---|
| 29 | public static void IsTrueWithMessage(this bool condition, string message)
|
---|
| 30 | {
|
---|
| 31 | if (!condition)
|
---|
| 32 | throw new ArgumentException(message);
|
---|
| 33 | }
|
---|
| 34 |
|
---|
| 35 | [DebuggerStepThrough]
|
---|
| 36 | public static void AssertNotNull(object obj)
|
---|
| 37 | {
|
---|
| 38 | Verify.IsTrue(obj != null);
|
---|
| 39 | }
|
---|
| 40 |
|
---|
| 41 | public static void VerifyNotNull(this object obj, string paramName)
|
---|
| 42 | {
|
---|
| 43 | if (obj == null)
|
---|
| 44 | throw new ArgumentNullException(paramName);
|
---|
| 45 | }
|
---|
| 46 |
|
---|
| 47 | public static void VerifyNotNull(this object obj)
|
---|
| 48 | {
|
---|
| 49 | VerifyNotNull(obj, "value");
|
---|
| 50 | }
|
---|
| 51 |
|
---|
| 52 | [DebuggerStepThrough]
|
---|
| 53 | public static void AssertIsNotNaN(this double d)
|
---|
| 54 | {
|
---|
| 55 | Verify.IsTrue(!Double.IsNaN(d));
|
---|
| 56 | }
|
---|
| 57 |
|
---|
| 58 | [DebuggerStepThrough]
|
---|
| 59 | public static void AssertIsFinite(this double d)
|
---|
| 60 | {
|
---|
| 61 | Verify.IsTrue(!Double.IsInfinity(d) && !(Double.IsNaN(d)));
|
---|
| 62 | }
|
---|
| 63 | }
|
---|
| 64 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.