Skip to content

Commit 0f6c630

Browse files
committed
Use xunit.skippablefact
1 parent 3b26804 commit 0f6c630

File tree

5 files changed

+10
-48
lines changed

5 files changed

+10
-48
lines changed

tests/NRedisStack.Tests/EndpointsFixture.cs

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using StackExchange.Redis;
22
using System.Text.Json;
3+
using Xunit;
34

45
namespace NRedisStack.Tests;
56

@@ -85,10 +86,7 @@ public void Dispose()
8586

8687
public ConnectionMultiplexer GetConnectionById(ConfigurationOptions configurationOptions, string id)
8788
{
88-
if (!redisEndpoints.ContainsKey(id))
89-
{
90-
throw new Exception($"The connection with id '{id}' is not configured.");
91-
}
89+
Skip.IfNot(redisEndpoints.ContainsKey(id), $"The connection with id '{id}' is not configured.");
9290

9391
return redisEndpoints[id].CreateConnection(configurationOptions);
9492
}

tests/NRedisStack.Tests/NRedisStack.Tests.csproj

+4-3
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,11 @@
2828
<PackageReference Include="NetTopologySuite" Version="2.5.0" />
2929
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" />
3030
<PackageReference Include="StackExchange.Redis" Version="2.8.16" />
31-
<PackageReference Include="xunit" Version="2.4.1" />
32-
<PackageReference Include="xunit.assert" Version="2.4.1" />
33-
<PackageReference Include="BouncyCastle.Cryptography" Version="2.2.0" />
31+
<PackageReference Include="xunit" Version="2.5.3" />
32+
<PackageReference Include="xunit.assert" Version="2.5.3" />
33+
<PackageReference Include="BouncyCastle.Cryptography" Version="2.3.1" />
3434
<PackageReference Include="Microsoft.Azure.StackExchangeRedis" Version="3.1.0" />
35+
<PackageReference Include="Xunit.SkippableFact" Version="1.4.13" />
3536
</ItemGroup>
3637

3738
<ItemGroup>

tests/NRedisStack.Tests/SkipIfRedisAttribute.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public enum Is
1414
}
1515

1616
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
17-
public class SkipIfRedisAttribute : TheoryAttribute
17+
public class SkipIfRedisAttribute : SkippableTheoryAttribute
1818
{
1919
private readonly string _targetVersion;
2020
private readonly Comparison _comparison;

tests/NRedisStack.Tests/TargetEnvironmentAttribute.cs

-36
This file was deleted.

tests/NRedisStack.Tests/TokenBasedAuthentication/AuthenticationTests.cs

+3-4
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,23 @@
66

77
namespace NRedisStack.Tests.TokenBasedAuthentication
88
{
9-
public class AuthenticationTests : AbstractNRedisStackTest
9+
public class AuthenticationTests(EndpointsFixture endpointsFixture) : AbstractNRedisStackTest(endpointsFixture)
1010
{
1111
static readonly string key = "myKey";
1212
static readonly string value = "myValue";
1313
static readonly string index = "myIndex";
1414
static readonly string field = "myField";
1515
static readonly string alias = "myAlias";
16-
public AuthenticationTests(RedisFixture redisFixture) : base(redisFixture) { }
1716

18-
[TargetEnvironment("standalone-entraid-acl")]
17+
[SkippableFact]
1918
public void TestTokenBasedAuthentication()
2019
{
2120

2221
var configurationOptions = new ConfigurationOptions().ConfigureForAzureWithTokenCredentialAsync(new DefaultAzureCredential()).Result!;
2322
configurationOptions.Ssl = false;
2423
configurationOptions.AbortOnConnectFail = true; // Fail fast for the purposes of this sample. In production code, this should remain false to retry connections on startup
2524

26-
ConnectionMultiplexer? connectionMultiplexer = redisFixture.GetConnectionById(configurationOptions, "standalone-entraid-acl");
25+
ConnectionMultiplexer? connectionMultiplexer = GetConnection(configurationOptions, "standalone-entraid-acl");
2726

2827
IDatabase db = connectionMultiplexer.GetDatabase();
2928

0 commit comments

Comments
 (0)