SortedSet 测试

master
bicijinlian 7 years ago
parent ca6c775e90
commit f13330aa85

@ -166,6 +166,67 @@ namespace RedisStudyTest
} }
#endregion #endregion
#region MyRegion
[Fact]
public void SortedSetLength_NotKey_Test()
{
var memberCount = redisSortedSetStudy.SortedSetLength(defaultRedisKey);
Assert.Equal(0, memberCount);
}
/// <summary>
/// 排它性参数Exclude设置 测试
/// </summary>
[Fact]
public void SortedSetLength_Exclude_Test()
{
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);
//默认Exclude.None [Start,Stop]
var memberCount = redisSortedSetStudy.SortedSetLength(defaultRedisKey, 2, 4, Exclude.None, CommandFlags.None);
Assert.Equal(3, memberCount);
//Exclude.Start (Start,Stop]
memberCount = redisSortedSetStudy.SortedSetLength(defaultRedisKey, 2, 4, Exclude.Start, CommandFlags.None);
Assert.Equal(2, memberCount);
//Exclude.Stop [Start,Stop)
memberCount = redisSortedSetStudy.SortedSetLength(defaultRedisKey, 2, 4, Exclude.Stop, CommandFlags.None);
Assert.Equal(2, memberCount);
//Exclude.Both (Start,Stop)
memberCount = redisSortedSetStudy.SortedSetLength(defaultRedisKey, 2, 4, Exclude.Both, CommandFlags.None);
Assert.Equal(1, memberCount);
}
[Fact]
public void SortedSetLengthTest()
{
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 清理 #region 清理
public void Dispose() public void Dispose()
{ {

@ -101,7 +101,7 @@ namespace RedisStuy
/// <param name="key">键</param> /// <param name="key">键</param>
/// <param name="min">最小值</param> /// <param name="min">最小值</param>
/// <param name="max">最大值</param> /// <param name="max">最大值</param>
/// <param name="exclude">在执行范围查询时默认情况下Start/Stop 限制是包含的;但是,两者也可以单独指定为排他性的。</param> /// <param name="exclude">在执行范围查询时排他性设置:默认情况下Start/Stop 限制是包含的;但是,两者也可以单独指定为排他性的。</param>
/// <param name="flags">命令参数</param> /// <param name="flags">命令参数</param>
/// <returns> /// <returns>
/// 指定条件的元素个数 /// 指定条件的元素个数

Loading…
Cancel
Save