Repository: microsoft/garnet
File: test/Garnet.test/RespListTests.cs (C#)

Code before:

            var expectedResponse = $"-{Encoding.ASCII.GetString(CmdStrings.RESP_ERR_WRONG_TYPE)}\r\n";
            var actualValue = Encoding.ASCII.GetString(len).Substring(0, expectedResponse.Length);
            Assert.AreEqual(expectedResponse, actualValue);
        }

        [Test]
        public void CheckEmptyListKeyRemoved()
        {
            using var redis = ConnectionMultiplexer.Connect(TestUtils.GetConfig());
            var key = new RedisKey("user1:list");
            var db = redis.GetDatabase(0);
            var values = new[] { new RedisValue("Hello"), new RedisValue("World") };
            var result = db.ListRightPush(key, values);
            Assert.AreEqual(2, result);

            var actualMembers = db.ListRightPop(key, 2);
            Assert.AreEqual(values.Length, actualMembers.Length);

            var keyExists = db.KeyExists(key);
            Assert.IsFalse(keyExists);
        }

        [Test]
        public void CanDoBasicLMPOP()
        {
            using var redis = ConnectionMultiplexer.Connect(TestUtils.GetConfig());
            var db = redis.GetDatabase(0);

            var key1 = new RedisKey("mykey1");
            var key1Values = new[] { new RedisValue("myval1"), new RedisValue("myval2"), new RedisValue("myval3") };

            var key2 = new RedisKey("mykey2");
            var key2Values = new[] { new RedisValue("myval4") };

            var pushed = db.ListRightPush(key1, key1Values);
            Assert.AreEqual(3, pushed);
            pushed = db.ListRightPush(key2, key2Values);
            Assert.AreEqual(1, pushed);

            var result = db.ListLeftPop(new[] { new RedisKey("test") }, 3);
            Assert.True(result.IsNull);

            result = db.ListLeftPop(new[] { key1, key2 }, 3);
            Assert.AreEqual(key1, result.Key);
            Assert.AreEqual(key1Values, result.Values);

            result = db.ListLeftPop(new[] { new RedisKey("test"), key2 }, 2);
            Assert.AreEqual(key2, result.Key);
            Assert.AreEqual(key2Values, result.Values);
        }

Review comment (suggestion):
I would add a few test cases here:
1. LeftPop without a COUNT
2. Repeat calls for RightPop
3. You can use db.Execute to call LMPOP with numkeys that doesn't match the number of keys provided
4. Call LMPOP without RIGHT / LEFT

Code after:

            var expectedResponse = $"-{Encoding.ASCII.GetString(CmdStrings.RESP_ERR_WRONG_TYPE)}\r\n";
            var actualValue = Encoding.ASCII.GetString(len).Substring(0, expectedResponse.Length);
            Assert.AreEqual(expectedResponse, actualValue);
        }

        [Test]
        public void CheckEmptyListKeyRemoved()
        {
            using var redis = ConnectionMultiplexer.Connect(TestUtils.GetConfig());
            var key = new RedisKey("user1:list");
            var db = redis.GetDatabase(0);
            var values = new[] { new RedisValue("Hello"), new RedisValue("World") };
            var result = db.ListRightPush(key, values);
            Assert.AreEqual(2, result);

            var actualMembers = db.ListRightPop(key, 2);
            Assert.AreEqual(values.Length, actualMembers.Length);

            var keyExists = db.KeyExists(key);
            Assert.IsFalse(keyExists);
        }

        [Test]
        public void CanDoBasicLMPOP()
        {
            using var redis = ConnectionMultiplexer.Connect(TestUtils.GetConfig());
            var db = redis.GetDatabase(0);

            var key1 = new RedisKey("mykey1");
            var key1Values = new[] { new RedisValue("myval1"), new RedisValue("myval2"), new RedisValue("myval3") };

            var key2 = new RedisKey("mykey2");
            var key2Values = new[] { new RedisValue("myval4") };

            var pushed = db.ListRightPush(key1, key1Values);
            Assert.AreEqual(3, pushed);
            pushed = db.ListRightPush(key2, key2Values);
            Assert.AreEqual(1, pushed);

            var result = db.ListLeftPop(new[] { new RedisKey("test") }, 3);
            Assert.True(result.IsNull);

            result = db.ListRightPop(new[] { new RedisKey("test") }, 3);
            Assert.True(result.IsNull);

            result = db.ListLeftPop(new[] { key1, key2 }, 3);
            Assert.AreEqual(key1, result.Key);
            Assert.AreEqual(key1Values, result.Values);

            result = db.ListRightPop(new[] { new RedisKey("test"), key2 }, 2);