diff --git a/RedisStudyTest/RedisSortedSetStudyTest.cs b/RedisStudyTest/RedisSortedSetStudyTest.cs index 420388c..8e2f842 100644 --- a/RedisStudyTest/RedisSortedSetStudyTest.cs +++ b/RedisStudyTest/RedisSortedSetStudyTest.cs @@ -372,10 +372,59 @@ namespace RedisStudyTest #region SortedSetScore + [Fact] + public void SortedSetScore_NotKey_Test() + { + var setScore = redisSortedSetStudy.SortedSetScore(defaultRedisKey,"first"); + + Assert.False(setScore.HasValue); + } + + [Fact] + public void SortedSetScore_NotMember_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); + + var setScore = redisSortedSetStudy.SortedSetScore(defaultRedisKey, "mysix"); + + Assert.False(setScore.HasValue); + } + [Fact] public void SortedSetScoreTest() { - //redisSortedSetStudy.SortedSetScore(); + 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 setScore = redisSortedSetStudy.SortedSetScore(defaultRedisKey, "first"); + Assert.Equal(1, setScore); + + setScore = redisSortedSetStudy.SortedSetScore(defaultRedisKey, "second"); + Assert.Equal(2, setScore); + + setScore = redisSortedSetStudy.SortedSetScore(defaultRedisKey, "third"); + Assert.Equal(3, setScore); + + setScore = redisSortedSetStudy.SortedSetScore(defaultRedisKey, "four"); + Assert.Equal(4, setScore); + + setScore = redisSortedSetStudy.SortedSetScore(defaultRedisKey, "five"); + Assert.Equal(5, setScore); } #endregion @@ -957,8 +1006,6 @@ namespace RedisStudyTest } #endregion - - #region 清理 public void Dispose() {