|
|
@ -58,6 +58,18 @@ namespace RedisStudyTest
|
|
|
|
Assert.Equal("first", first);
|
|
|
|
Assert.Equal("first", first);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
|
|
|
public void ListLeftPushsTest()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
RedisValue[] listValues = new RedisValue[]
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
"first",
|
|
|
|
|
|
|
|
"secnd",
|
|
|
|
|
|
|
|
"third"
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
var listLenth = redisListStudy.ListLeftPush(defaultRedisKey, listValues);
|
|
|
|
|
|
|
|
Assert.Equal(3, listLenth);
|
|
|
|
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region ListRightPush
|
|
|
|
#region ListRightPush
|
|
|
@ -76,6 +88,20 @@ namespace RedisStudyTest
|
|
|
|
var first = redisListStudy.ListRightPop(defaultRedisKey);
|
|
|
|
var first = redisListStudy.ListRightPop(defaultRedisKey);
|
|
|
|
Assert.Equal("first", first);
|
|
|
|
Assert.Equal("first", first);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
|
|
|
public void ListRightPushsTest()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
RedisValue[] listValues = new RedisValue[]
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
"first",
|
|
|
|
|
|
|
|
"secnd",
|
|
|
|
|
|
|
|
"third"
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
var listLenth = redisListStudy.ListRightPush(defaultRedisKey, listValues);
|
|
|
|
|
|
|
|
Assert.Equal(3, listLenth);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region ListInsertBefore
|
|
|
|
#region ListInsertBefore
|
|
|
@ -162,7 +188,7 @@ namespace RedisStudyTest
|
|
|
|
{
|
|
|
|
{
|
|
|
|
redisListStudy.ListLeftPush(defaultRedisKey, "first");
|
|
|
|
redisListStudy.ListLeftPush(defaultRedisKey, "first");
|
|
|
|
|
|
|
|
|
|
|
|
redisListStudy.ListSetByIndex(defaultRedisKey,0,"firstSetByIndex");
|
|
|
|
redisListStudy.ListSetByIndex(defaultRedisKey, 0, "firstSetByIndex");
|
|
|
|
|
|
|
|
|
|
|
|
var first = redisListStudy.ListLeftPop(defaultRedisKey);
|
|
|
|
var first = redisListStudy.ListLeftPop(defaultRedisKey);
|
|
|
|
|
|
|
|
|
|
|
@ -170,6 +196,114 @@ namespace RedisStudyTest
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region ListLength
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
|
|
|
public void ListLengthNotKeyTest()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var listLenth = redisListStudy.ListLength(defaultRedisKey);
|
|
|
|
|
|
|
|
Assert.Equal(0, listLenth);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
|
|
|
public void ListLengthTest()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
redisListStudy.ListLeftPush(defaultRedisKey, "first");
|
|
|
|
|
|
|
|
var listLenth = redisListStudy.ListLength(defaultRedisKey);
|
|
|
|
|
|
|
|
Assert.Equal(1, listLenth);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
redisListStudy.ListLeftPush(defaultRedisKey, "second");
|
|
|
|
|
|
|
|
listLenth = redisListStudy.ListLength(defaultRedisKey);
|
|
|
|
|
|
|
|
Assert.Equal(2, listLenth);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
redisListStudy.ListLeftPush(defaultRedisKey, "third");
|
|
|
|
|
|
|
|
listLenth = redisListStudy.ListLength(defaultRedisKey);
|
|
|
|
|
|
|
|
Assert.Equal(3, listLenth);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region ListRange
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
|
|
|
public void ListRangeNotKeyTest()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
RedisValue[] values = redisListStudy.ListRange(defaultRedisKey, 0, -1);
|
|
|
|
|
|
|
|
Assert.Empty(values);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
|
|
|
public void ListRangeTest()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
redisListStudy.ListLeftPush(defaultRedisKey, "first");
|
|
|
|
|
|
|
|
var values = redisListStudy.ListRange(defaultRedisKey, 0, -1);
|
|
|
|
|
|
|
|
Assert.NotEmpty(values);
|
|
|
|
|
|
|
|
Assert.Contains("first", values);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
redisListStudy.ListLeftPush(defaultRedisKey, "second");
|
|
|
|
|
|
|
|
values = redisListStudy.ListRange(defaultRedisKey, 0, -1);
|
|
|
|
|
|
|
|
Assert.NotEmpty(values);
|
|
|
|
|
|
|
|
Assert.Contains("first", values);
|
|
|
|
|
|
|
|
Assert.Contains("second", values);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region ListRemove
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
|
|
|
public void ListRemoveNotKeyTest()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var removeNum = redisListStudy.ListRemove(defaultRedisKey, "first");
|
|
|
|
|
|
|
|
Assert.Equal(0, removeNum);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
|
|
|
public void ListRemoveTest()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var removeNum = 0L;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
redisListStudy.ListLeftPush(defaultRedisKey, new RedisValue[] { "first", "second", "third", "four" });
|
|
|
|
|
|
|
|
removeNum = redisListStudy.ListRemove(defaultRedisKey, "first", 0);
|
|
|
|
|
|
|
|
Assert.Equal(1, removeNum);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
redisListStudy.ListLeftPush(defaultRedisKey, new RedisValue[] { "third", "four" });
|
|
|
|
|
|
|
|
removeNum = redisListStudy.ListRemove(defaultRedisKey, "third", 0);
|
|
|
|
|
|
|
|
Assert.Equal(2, removeNum);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
redisListStudy.ListLeftPush(defaultRedisKey, new RedisValue[] { "1", "2", "1", "2", "1", "2" });
|
|
|
|
|
|
|
|
removeNum = redisListStudy.ListRemove(defaultRedisKey, "2", 0);
|
|
|
|
|
|
|
|
Assert.Equal(3, removeNum);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region ListTrim
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
|
|
|
public void ListTrimNotKeyTest()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
redisListStudy.ListTrim(defaultRedisKey, 2, 5);
|
|
|
|
|
|
|
|
var listCount = redisListStudy.ListLength(defaultRedisKey);
|
|
|
|
|
|
|
|
Assert.Equal(0, listCount);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
|
|
|
public void ListTrimTest()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
RedisValue[] values = new RedisValue[]
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
"first",
|
|
|
|
|
|
|
|
"second",
|
|
|
|
|
|
|
|
"third",
|
|
|
|
|
|
|
|
"four"
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
redisListStudy.ListLeftPush(defaultRedisKey, values);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
redisListStudy.ListTrim(defaultRedisKey,1,-1);
|
|
|
|
|
|
|
|
Assert.Equal(3, redisListStudy.ListLength(defaultRedisKey));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
redisListStudy.ListTrim(defaultRedisKey, 2, -1);
|
|
|
|
|
|
|
|
Assert.Equal(1, redisListStudy.ListLength(defaultRedisKey));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region 清理
|
|
|
|
#region 清理
|
|
|
|
public void Dispose()
|
|
|
|
public void Dispose()
|
|
|
|
{
|
|
|
|
{
|
|
|
|