-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathIsNotZero.cs
65 lines (59 loc) · 2.52 KB
/
IsNotZero.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
namespace AssertLibrary
{
using System.Diagnostics;
using System.Globalization;
public static partial class Assert
{
/// <summary>
/// Asserts that the given integer is negative.
/// </summary>
/// <param name="n">Number to check if it's negative</param>
/// <param name="variableName">Variable name to include in the error message (optional)</param>
public static void IsNotZero(int n, string variableName = null)
{
Check(n != 0, IsNotZeroMessage(variableName));
}
/// <summary>
/// Asserts that the given integer is negative.
/// </summary>
/// <param name="n">Number to check if it's negative</param>
/// <param name="variableName">Variable name to include in the error message (optional)</param>
public static void IsNotZero(long n, string variableName = null)
{
Check(n != 0, IsNotZeroMessage(variableName));
}
/// <summary>
/// Asserts that the given integer is negative.
/// </summary>
/// <param name="n">Number to check if it's negative</param>
/// <param name="variableName">Variable name to include in the error message (optional)</param>
public static void IsNotZero(float n, string variableName = null)
{
Check(n != 0, IsNotZeroMessage(variableName));
}
/// <summary>
/// Asserts that the given integer is negative.
/// </summary>
/// <param name="n">Number to check if it's negative</param>
/// <param name="variableName">Variable name to include in the error message (optional)</param>
public static void IsNotZero(double n, string variableName = null)
{
Check(n != 0, IsNotZeroMessage(variableName));
}
/// <summary>
/// Asserts that the given integer is negative.
/// </summary>
/// <param name="n">Number to check if it's negative</param>
/// <param name="variableName">Variable name to include in the error message (optional)</param>
public static void IsNotZero(decimal n, string variableName = null)
{
Check(n != 0, IsNotZeroMessage(variableName));
}
private static string IsNotZeroMessage(string variableName)
{
return variableName == null ?
"Shouldn't be zero at this point." :
string.Format(CultureInfo.CurrentCulture, "\"{0}\" shouldn't be zero at this point.", variableName);
}
}
}