-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy pathNAssert.cs
67 lines (57 loc) · 2.55 KB
/
NAssert.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
66
67
using System.Diagnostics.CodeAnalysis;
using NUnit.Framework;
namespace CodeJam
{
/// <summary>NUnit NotNull assertion with nullable annotations</summary>
public static class NAssert
{
#pragma warning disable CS8777 // Parameter must have a non-null value when exiting.
#region NotNull
/// <summary>
/// Verifies that the object that is passed in is not equal to <see langword="null" />. Returns without throwing an
/// exception when inside a multiple assert block.
/// </summary>
/// <param name="anObject">The object that is to be tested</param>
/// <param name="message">The message to display in case of failure</param>
/// <param name="args">Array of objects to be used in formatting the message</param>
/// <remarks><see cref="Assert.NotNull(object,string,object[])"/></remarks>
public static void NotNull([NotNull] object? anObject, string message, params object?[]? args)
{
Assert.IsNotNull(anObject, message, args);
}
/// <summary>
/// Verifies that the object that is passed in is not equal to <see langword="null" />. Returns without throwing an
/// exception when inside a multiple assert block.
/// </summary>
/// <param name="anObject">The object that is to be tested</param>
/// <param name="message">The message to display in case of failure</param>
/// <param name="args">Array of objects to be used in formatting the message</param>
/// <remarks><see cref="Assert.IsNotNull(object,string,object[])"/></remarks>
public static void IsNotNull([NotNull] object? anObject, string message, params object?[]? args)
{
Assert.IsNotNull(anObject, message, args);
}
/// <summary>
/// Verifies that the object that is passed in is not equal to <see langword="null" />. Returns without throwing an
/// exception when inside a multiple assert block.
/// </summary>
/// <param name="anObject">The object that is to be tested</param>
/// <remarks><see cref="Assert.NotNull(object)"/></remarks>
public static void NotNull([NotNull] object? anObject)
{
Assert.IsNotNull(anObject);
}
/// <summary>
/// Verifies that the object that is passed in is not equal to <see langword="null" />. Returns without throwing an
/// exception when inside a multiple assert block.
/// </summary>
/// <param name="anObject">The object that is to be tested</param>
/// <remarks><see cref="Assert.IsNotNull(object)"/></remarks>
public static void IsNotNull([NotNull] object? anObject)
{
Assert.IsNotNull(anObject);
}
#endregion
#pragma warning restore CS8777 // Parameter must have a non-null value when exiting.
}
}