forked from redis/NRedisStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue redis#195 In the integration workflows, publish the binary package into a local Nuget source and use it as a binary, to make sure it works that way.
- Loading branch information
Showing
3 changed files
with
78 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
using NRedisStack; | ||
using NRedisStack.Core.DataTypes; | ||
using StackExchange.Redis; | ||
|
||
public class PackageTest | ||
{ | ||
public static void Main() | ||
{ | ||
ConfigurationOptions configurationOptions = new ConfigurationOptions(); | ||
configurationOptions.SyncTimeout = 20000; | ||
configurationOptions.EndPoints.Add("localhost:6379"); | ||
ConnectionMultiplexer redis = ConnectionMultiplexer.Connect(configurationOptions); | ||
IDatabase db = redis.GetDatabase(); | ||
|
||
db.Execute("FLUSHALL"); | ||
|
||
db.SortedSetAdd("X", "foo", 5.1); | ||
db.SortedSetAdd("X", "bar", 8.4); | ||
db.SortedSetAdd("X", "baz", 6.7); | ||
|
||
var result = db.BzmPop(0, new[] { new RedisKey("X") }, MinMaxModifier.Max, count: 2); | ||
Assert(2 == result!.Item2.Count); | ||
Assert("bar" == result.Item2[0].Value); | ||
Assert("baz" == result.Item2[1].Value); | ||
|
||
result = db.BzmPop(0, "X", MinMaxModifier.Min); | ||
Assert(1 == result!.Item2.Count); | ||
Assert("foo" == result!.Item2[0].Value); | ||
|
||
db.SortedSetAdd("X", "foo", 5.1); | ||
db.SortedSetAdd("X", "bar", 8.4); | ||
db.SortedSetAdd("X", "baz", 6.7); | ||
|
||
var singleResult = db.BzPopMin("X", 0); | ||
Assert("foo" == singleResult!.Item2.Value); | ||
|
||
singleResult = db.BzPopMax("X", 0); | ||
Assert("bar" == singleResult!.Item2.Value); | ||
|
||
Console.WriteLine("All good."); | ||
} | ||
|
||
/// <summary> | ||
/// Poor Man's assert, since we don't want to depend on NUnit. | ||
/// </summary> | ||
private static void Assert(bool condition) | ||
{ | ||
if (!condition) | ||
{ | ||
throw new System.Exception(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="NRedisStack" Version="*" /> | ||
</ItemGroup> | ||
|
||
</Project> |