-
-
Notifications
You must be signed in to change notification settings - Fork 540
/
EnumAssertionsExtensions.cs
36 lines (33 loc) · 1.16 KB
/
EnumAssertionsExtensions.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
using System;
using System.Diagnostics;
using System.Diagnostics.Contracts;
using FluentAssertions.Execution;
using FluentAssertions.Primitives;
namespace FluentAssertions;
/// <summary>
/// Contains an extension method for custom assertions in unit tests related to Enum objects.
/// </summary>
[DebuggerNonUserCode]
public static class EnumAssertionsExtensions
{
/// <summary>
/// Returns an <see cref="EnumAssertions{TEnum, TAssertions}"/> object that can be used to assert the
/// current <typeparamref name="TEnum"/>.
/// </summary>
[Pure]
public static EnumAssertions<TEnum> Should<TEnum>(this TEnum @enum)
where TEnum : struct, Enum
{
return new EnumAssertions<TEnum>(@enum, AssertionChain.GetOrCreate());
}
/// <summary>
/// Returns an <see cref="EnumAssertions{TEnum, TAssertions}"/> object that can be used to assert the
/// current <typeparamref name="TEnum"/>.
/// </summary>
[Pure]
public static NullableEnumAssertions<TEnum> Should<TEnum>(this TEnum? @enum)
where TEnum : struct, Enum
{
return new NullableEnumAssertions<TEnum>(@enum, AssertionChain.GetOrCreate());
}
}