sorted set study

master
bicijinlian 7 years ago
parent f13330aa85
commit 86796b7123

@ -166,7 +166,7 @@ namespace RedisStudyTest
}
#endregion
#region MyRegion
#region SortedSetLength
[Fact]
public void SortedSetLength_NotKey_Test()
@ -227,6 +227,75 @@ namespace RedisStudyTest
#endregion
#region SortedSetLengthByValue 分数相同则字典排序
[Fact]
public void SortedSetLengthByValue_NotKey_Test()
{
var memberCount = redisSortedSetStudy.SortedSetLengthByValue(defaultRedisKey,1,200);
Assert.Equal(0, memberCount);
}
/// <summary>
/// 排它性参数Exclude设置 测试
/// </summary>
[Fact]
public void SortedSetLengthByValue_Exclude_Test()
{
//todo:排序规则,还不清楚
SortedSetEntry[] sortedSetEntries = new SortedSetEntry[]
{
new SortedSetEntry("Andy",0),
new SortedSetEntry("and",0),
new SortedSetEntry("And",0),
new SortedSetEntry("Banana",0),
new SortedSetEntry("color",0),
new SortedSetEntry("query",0),
new SortedSetEntry("remove",0),
new SortedSetEntry("101",0),
new SortedSetEntry("304",0),
new SortedSetEntry("王高峰",0),
new SortedSetEntry("刘山东",0),
};
redisSortedSetStudy.SortedSetAdd(defaultRedisKey, sortedSetEntries);
//默认Exclude.None [Start,Stop]
var memberCount = redisSortedSetStudy.SortedSetLengthByValue(defaultRedisKey, "1", "B", Exclude.None, CommandFlags.None);
Assert.Equal(4, memberCount);
////Exclude.Start (Start,Stop]
//memberCount = redisSortedSetStudy.SortedSetLengthByValue(defaultRedisKey, 2, 4, Exclude.Start, CommandFlags.None);
//Assert.Equal(2, memberCount);
////Exclude.Stop [Start,Stop)
//memberCount = redisSortedSetStudy.SortedSetLengthByValue(defaultRedisKey, 2, 4, Exclude.Stop, CommandFlags.None);
//Assert.Equal(2, memberCount);
////Exclude.Both (Start,Stop)
//memberCount = redisSortedSetStudy.SortedSetLengthByValue(defaultRedisKey, 2, 4, Exclude.Both, CommandFlags.None);
//Assert.Equal(1, memberCount);
}
[Fact]
public void SortedSetLengthByValueTest()
{
SortedSetEntry[] sortedSetEntries = new SortedSetEntry[]
{
new SortedSetEntry("first",1),
new SortedSetEntry("second",2),
new SortedSetEntry("third",3),
new SortedSetEntry("four",4),
new SortedSetEntry("five",5),
};
redisSortedSetStudy.SortedSetAdd(defaultRedisKey, sortedSetEntries);
var memberCount = redisSortedSetStudy.SortedSetLength(defaultRedisKey, 1, 5);
Assert.Equal(sortedSetEntries.Length, memberCount);
}
#endregion
#region 清理
public void Dispose()
{

Loading…
Cancel
Save