Skip to content

Commit

Permalink
Use xunit.skippablefact
Browse files Browse the repository at this point in the history
  • Loading branch information
uglide committed Nov 29, 2024
1 parent 3b26804 commit 0f6c630
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 48 deletions.
6 changes: 2 additions & 4 deletions tests/NRedisStack.Tests/EndpointsFixture.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using StackExchange.Redis;
using System.Text.Json;
using Xunit;

namespace NRedisStack.Tests;

Expand Down Expand Up @@ -85,10 +86,7 @@ public void Dispose()

public ConnectionMultiplexer GetConnectionById(ConfigurationOptions configurationOptions, string id)
{
if (!redisEndpoints.ContainsKey(id))
{
throw new Exception($"The connection with id '{id}' is not configured.");
}
Skip.IfNot(redisEndpoints.ContainsKey(id), $"The connection with id '{id}' is not configured.");

return redisEndpoints[id].CreateConnection(configurationOptions);
}
Expand Down
7 changes: 4 additions & 3 deletions tests/NRedisStack.Tests/NRedisStack.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@
<PackageReference Include="NetTopologySuite" Version="2.5.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" />
<PackageReference Include="StackExchange.Redis" Version="2.8.16" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.assert" Version="2.4.1" />
<PackageReference Include="BouncyCastle.Cryptography" Version="2.2.0" />
<PackageReference Include="xunit" Version="2.5.3" />
<PackageReference Include="xunit.assert" Version="2.5.3" />
<PackageReference Include="BouncyCastle.Cryptography" Version="2.3.1" />
<PackageReference Include="Microsoft.Azure.StackExchangeRedis" Version="3.1.0" />
<PackageReference Include="Xunit.SkippableFact" Version="1.4.13" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion tests/NRedisStack.Tests/SkipIfRedisAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public enum Is
}

[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
public class SkipIfRedisAttribute : TheoryAttribute
public class SkipIfRedisAttribute : SkippableTheoryAttribute
{
private readonly string _targetVersion;
private readonly Comparison _comparison;
Expand Down
36 changes: 0 additions & 36 deletions tests/NRedisStack.Tests/TargetEnvironmentAttribute.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,23 @@

namespace NRedisStack.Tests.TokenBasedAuthentication
{
public class AuthenticationTests : AbstractNRedisStackTest
public class AuthenticationTests(EndpointsFixture endpointsFixture) : AbstractNRedisStackTest(endpointsFixture)
{
static readonly string key = "myKey";
static readonly string value = "myValue";
static readonly string index = "myIndex";
static readonly string field = "myField";
static readonly string alias = "myAlias";
public AuthenticationTests(RedisFixture redisFixture) : base(redisFixture) { }

[TargetEnvironment("standalone-entraid-acl")]
[SkippableFact]
public void TestTokenBasedAuthentication()
{

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

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

IDatabase db = connectionMultiplexer.GetDatabase();

Expand Down

0 comments on commit 0f6c630

Please sign in to comment.