forked from CirrusRedOrg/EntityFrameworkCore.Jet
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathJetConditionAttribute.cs
More file actions
39 lines (33 loc) · 1.32 KB
/
JetConditionAttribute.cs
File metadata and controls
39 lines (33 loc) · 1.32 KB
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
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Linq;
using System.Threading.Tasks;
using EntityFrameworkCore.Jet.Data;
using System.Data.OleDb;
using Microsoft.EntityFrameworkCore.TestUtilities.Xunit;
namespace EntityFrameworkCore.Jet.FunctionalTests.TestUtilities
{
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class)]
public sealed class JetConditionAttribute(JetCondition conditions) : Attribute, ITestCondition
{
public JetCondition Conditions { get; set; } = conditions;
public ValueTask<bool> IsMetAsync()
{
var isMet = true;
if (Conditions.HasFlag(JetCondition.IsNotCI))
{
isMet &= !TestEnvironment.IsCI;
}
return ValueTask.FromResult(isMet);
}
public string SkipReason =>
// ReSharper disable once UseStringInterpolation
string.Format(
"The test Jet does not meet these conditions: '{0}'",
string.Join(
", ", Enum.GetValues(typeof(JetCondition))
.Cast<Enum>()
.Where(f => Conditions.HasFlag(f))
.Select(f => Enum.GetName(typeof(JetCondition), f))));
}
}