forked from xunit/assert.xunit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SkipAsserts.cs
68 lines (61 loc) · 1.89 KB
/
SkipAsserts.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
68
#if XUNIT_NULLABLE
#nullable enable
using System.Diagnostics.CodeAnalysis;
#endif
using Xunit.Sdk;
namespace Xunit
{
#if XUNIT_VISIBILITY_INTERNAL
internal
#else
public
#endif
partial class Assert
{
/// <summary>
/// Skips the current test. Used when determining whether a test should be skipped
/// happens at runtime rather than at discovery time.
/// </summary>
/// <param name="reason">The message to indicate why the test was skipped</param>
#if XUNIT_NULLABLE
[DoesNotReturn]
#endif
public static void Skip(string reason)
{
GuardArgumentNotNull(nameof(reason), reason);
throw new SkipException(reason);
}
/// <summary>
/// Will skip the current test unless <paramref name="condition"/> evaluates to <c>true</c>.
/// </summary>
/// <param name="condition">When <c>true</c>, the test will continue to run; when <c>false</c>,
/// the test will be skipped</param>
/// <param name="reason">The message to indicate why the test was skipped</param>
#if XUNIT_NULLABLE
public static void SkipUnless([DoesNotReturnIf(false)] bool condition, string reason)
#else
public static void SkipUnless(bool condition, string reason)
#endif
{
GuardArgumentNotNull(nameof(reason), reason);
if (!condition)
throw new SkipException(reason);
}
/// <summary>
/// Will skip the current test when <paramref name="condition"/> evaluates to <c>true</c>.
/// </summary>
/// <param name="condition">When <c>true</c>, the test will be skipped; when <c>false</c>,
/// the test will continue to run</param>
/// <param name="reason">The message to indicate why the test was skipped</param>
#if XUNIT_NULLABLE
public static void SkipWhen([DoesNotReturnIf(true)] bool condition, string reason)
#else
public static void SkipWhen(bool condition, string reason)
#endif
{
GuardArgumentNotNull(nameof(reason), reason);
if (condition)
throw new SkipException(reason);
}
}
}