diff --git a/RedisStudyTest/RedisSortedSetStudyTest.cs b/RedisStudyTest/RedisSortedSetStudyTest.cs index aa83f28..3be8c9d 100644 --- a/RedisStudyTest/RedisSortedSetStudyTest.cs +++ b/RedisStudyTest/RedisSortedSetStudyTest.cs @@ -166,6 +166,67 @@ namespace RedisStudyTest } #endregion + #region MyRegion + + [Fact] + public void SortedSetLength_NotKey_Test() + { + var memberCount = redisSortedSetStudy.SortedSetLength(defaultRedisKey); + Assert.Equal(0, memberCount); + } + + /// + /// 排它性参数Exclude设置 测试 + /// + [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 清理 public void Dispose() { diff --git a/RedisStuy/RedisSortedSetStudy.cs b/RedisStuy/RedisSortedSetStudy.cs index 53f93a9..6ae6e21 100644 --- a/RedisStuy/RedisSortedSetStudy.cs +++ b/RedisStuy/RedisSortedSetStudy.cs @@ -101,7 +101,7 @@ namespace RedisStuy /// 键 /// 最小值 /// 最大值 - /// 在执行范围查询时,默认情况下,Start/Stop 限制是包含的;但是,两者也可以单独指定为排他性的。 + /// 在执行范围查询时排他性设置:默认情况下,Start/Stop 限制是包含的;但是,两者也可以单独指定为排他性的。 /// 命令参数 /// /// 指定条件的元素个数