DbFixtures.Redis
1.0.16
dotnet add package DbFixtures.Redis --version 1.0.16
NuGet\Install-Package DbFixtures.Redis -Version 1.0.16
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DbFixtures.Redis" Version="1.0.16" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DbFixtures.Redis" Version="1.0.16" />
<PackageReference Include="DbFixtures.Redis" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add DbFixtures.Redis --version 1.0.16
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: DbFixtures.Redis, 1.0.16"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package DbFixtures.Redis@1.0.16
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=DbFixtures.Redis&version=1.0.16
#tool nuget:?package=DbFixtures.Redis&version=1.0.16
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Fixtures Manager Redis Driver
An abstraction layer for the redis package to facilitate handling database fixtures for testing purposes, in a Redis database.
This package is ment to be used in conjunction with the dbfixtures package, but can also be used by itself.
Installation
dotnet add [path/to/your/csproj/file] package DbFixtures.Redis
Usage
This package exposes the following interface
public interface IDriver
{
// clears the specified "tables" of any content
public Task Truncate(string[] tableNames);
// inserts the supplied "rows" into the specified "table"
public Task InsertFixtures<T>(string tableName, T[] fixtures);
// cleanup and terminate the connection to the database
public Task Close();
}
Example
using Newtonsoft.Json;
using SharedLibs.Types;
using StackExchange.Redis;
namespace DbFixtures.Redis.Tests.E2E;
[Trait("Type", "E2E")]
public class RedisDriverTests : IAsyncDisposable
{
private readonly IConnectionMultiplexer _client;
private readonly IDatabase _db;
private readonly DbFixtures _dbFixtures;
public RedisDriverTests()
{
this._client = ConnectionMultiplexer.Connect(
new ConfigurationOptions
{
EndPoints = { "api_redis:6379" },
AbortOnConnectFail = false,
}
);
this._db = this._client.GetDatabase(0);
driver = new RedisDriver(
this._client, this._db,
new Dictionary<string, Types.KeyTypes>
{
{ "testHash", Types.KeyTypes.Hash },
{ "testList", Types.KeyTypes.List },
{ "testSet", Types.KeyTypes.Set },
{ "testStream", Types.KeyTypes.Stream },
{ "testString", Types.KeyTypes.String },
{ "anotherTestString", Types.KeyTypes.String },
}
);
this._dbFixtures = new DbFixtures([driver]);
this._db.KeyDelete("testHash");
this._db.KeyDelete("testList");
this._db.KeyDelete("testSet");
this._db.KeyDelete("testStream");
this._db.KeyDelete("testString");
this._db.KeyDelete("anotherTestString");
}
public async ValueTask DisposeAsync()
{
await this._dbFixtures.CloseDrivers();
}
[Fact]
public async Task InsertFixtures_ItShouldInsertTheProvidedValuesIntoTheSpecifiedKeys()
{
await this._db.StringSetAsync("anotherTestString", "delete me");
Assert.Equal("delete me", await this._db.StringGetAsync("anotherTestString"));
Assert.Equal(RedisValue.Null, await this._db.StringGetAsync("testString"));
Assert.Equal(0, await this._db.ListLengthAsync("testList"));
Assert.Equal(0, await this._db.SetLengthAsync("testSet"));
Assert.Equal(0, await this._db.StreamLengthAsync("testStream"));
Assert.Equal(0, await this._db.HashLengthAsync("testHash"));
string[] testListContent = ["list v1", "list v2", "list v3"];
string[] testSetContent = ["set v1", "set v2"];
await this._dbFixtures.InsertFixtures<string>(
["testString", "testList", "testSet", "anotherTestString"],
new Dictionary<string, string[]>
{
{ "testString", ["new str value"] },
{ "anotherTestString", [] },
{ "testList", testListContent },
{ "testSet", testSetContent },
}
);
Dictionary<string, string>[] testStreamContent = [
new Dictionary<string, string> {
{ "stream f1 k1", "stream f1 v1" },
{ "stream f1 k2", "stream f1 v2" },
},
new Dictionary<string, string> {
{ "stream f2 k1", "stream f2 v1" },
},
];
Dictionary<string, string> testHashContent = new Dictionary<string, string> {
{ "hash f1 k1", "hash f1 v1" },
{ "hash f2 k1", "hash f2 v1" },
{ "hash f2 k2", "hash f2 v2" },
};
await this._dbFixtures.InsertFixtures<Dictionary<string, string>>(
["testStream", "testHash"],
new Dictionary<string, Dictionary<string, string>[]>
{
{ "testStream", testStreamContent },
{ "testHash", [testHashContent] },
}
);
Assert.Equal(RedisValue.Null, await this._db.StringGetAsync("anotherTestString"));
Assert.Equal("new str value", await this._db.StringGetAsync("testString"));
Assert.Equal(3, await this._db.ListLengthAsync("testList"));
var actualTestListContent = (await this._db.ListRangeAsync("testList", 0, 100)).ToStringArray();
Array.Sort(actualTestListContent);
Assert.Equal(testListContent, actualTestListContent);
Assert.Equal(2, await this._db.SetLengthAsync("testSet"));
Assert.Equal(testSetContent, (await this._db.SetMembersAsync("testSet")).ToStringArray());
Assert.Equal(2, await this._db.StreamLengthAsync("testStream"));
Assert.Equal(
JsonConvert.SerializeObject(testStreamContent),
JsonConvert.SerializeObject(
(await this._db.StreamRangeAsync("testStream", "-", "+"))
.Select(entry => entry.Values.ToDictionary(nv => nv.Name.ToString(), nv => nv.Value.ToString()))
.ToArray()
)
);
Assert.Equal(3, await this._db.HashLengthAsync("testHash"));
Assert.Equal(
testHashContent,
(await this._db.HashGetAllAsync("testHash")).ToDictionary(entry => entry.Name.ToString(), entry => entry.Value.ToString())
);
}
}
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- DbFixtures.SharedLibs (>= 1.0.4)
- NRedisStack (>= 1.8.0)
-
net8.0
- DbFixtures.SharedLibs (>= 1.0.4)
- NRedisStack (>= 1.8.0)
-
net9.0
- DbFixtures.SharedLibs (>= 1.0.4)
- NRedisStack (>= 1.8.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.16 | 648 | 9/21/2026 |
| 1.0.15 | 1,214 | 9/9/2026 |
| 1.0.14 | 1,750 | 8/25/2026 |
| 1.0.13 | 1,241 | 8/12/2026 |
| 1.0.12 | 458 | 8/4/2026 |
| 1.0.11 | 186 | 8/3/2026 |
| 1.0.10 | 268 | 7/30/2026 |
| 1.0.9 | 615 | 7/17/2026 |
| 1.0.8 | 2,441 | 6/19/2026 |
| 1.0.7 | 1,281 | 5/29/2026 |
| 1.0.6 | 1,930 | 5/11/2026 |
| 1.0.5 | 3,415 | 3/18/2026 |
| 1.0.4 | 2,483 | 1/23/2026 |
| 1.0.3 | 8,155 | 9/18/2025 |
| 1.0.2 | 654 | 9/10/2025 |
| 1.0.1 | 661 | 8/16/2025 |
| 1.0.0 | 398 | 8/9/2025 |