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

Code before:
                var count = db.ListLength(key);
                Assert.AreEqual(0, count);
                count = db.ListLength(key);
                Assert.AreEqual(0, count);
                Assert.IsFalse(db.KeyExists(key));

                //LPOP
                var result = db.ListLeftPop(key);
                Assert.IsTrue(result.IsNull);
                result = db.ListLeftPop(key);
                Assert.IsTrue(result.IsNull);
                Assert.IsFalse(db.KeyExists(key));

                //RPOP
                result = db.ListRightPop(key);
                Assert.IsTrue(result.IsNull);
                result = db.ListRightPop(key);
                Assert.IsTrue(result.IsNull);
                Assert.IsFalse(db.KeyExists(key));

                //LPOP count
                var resultArray = db.ListLeftPop(key, 100);
                Assert.AreEqual(Array.Empty<RedisValue>(), resultArray);
                resultArray = db.ListLeftPop(key, 100);
                Assert.AreEqual(Array.Empty<RedisValue>(), resultArray);
                Assert.IsFalse(db.KeyExists(key));

                //RPOP count
                resultArray = db.ListRightPop(key, 100);
                Assert.AreEqual(Array.Empty<RedisValue>(), resultArray);
                resultArray = db.ListRightPop(key, 100);
                Assert.AreEqual(Array.Empty<RedisValue>(), resultArray);
                Assert.IsFalse(db.KeyExists(key));

                //LRANGE
                resultArray = db.ListRange(key);
                Assert.AreEqual(Array.Empty<RedisValue>(), resultArray);
                resultArray = db.ListRange(key);
                Assert.AreEqual(Array.Empty<RedisValue>(), resultArray);
                Assert.IsFalse(db.KeyExists(key));

                //LINDEX
                result = db.ListGetByIndex(key, 15);
                Assert.IsTrue(result.IsNull);
                result = db.ListGetByIndex(key, 15);
                Assert.IsTrue(result.IsNull);
                Assert.IsFalse(db.KeyExists(key));

                //LTRIM
                db.ListTrim(key, 0, 15);
                db.ListTrim(key, 0, 15);

Review comment (bug):
Might be good to add 2 more error test cases: wrong # of arguments & index our of range (both positive and negative)

Code after:
            var expectedResponse = "+OK\r\n";
            var actualValue = Encoding.ASCII.GetString(response).Substring(0, expectedResponse.Length);
            Assert.AreEqual(expectedResponse, actualValue);
        }

        [Test]
        public void CanReturnErrorLSETWhenNosuchkey()
        {
            using var lightClientRequest = TestUtils.CreateRequest();
            var response = lightClientRequest.SendCommand("LSET mylist 0 four");
            var expectedResponse = "-ERR no such key\r\n";
            var actualValue = Encoding.ASCII.GetString(response).Substring(0, expectedResponse.Length);
            Assert.AreEqual(expectedResponse, actualValue);
        }

        [Test]
        public void CanReturnErrorLSETWhenIndexNotInteger()
        {
            using var lightClientRequest = TestUtils.CreateRequest();
            _ = lightClientRequest.SendCommand("RPUSH mylist one two three");
            var response = lightClientRequest.SendCommand("LSET mylist a four");
            var expectedResponse = "-ERR value is not an integer or out of range.\r\n";
            var actualValue = Encoding.ASCII.GetString(response).Substring(0, expectedResponse.Length);
            Assert.AreEqual(expectedResponse, actualValue);
        }

        [Test]
        public void CanReturnErrorLSETWhenIndexOutRange()
        {
            using var lightClientRequest = TestUtils.CreateRequest();
            _ = lightClientRequest.SendCommand("RPUSH mylist one two three");
            var response = lightClientRequest.SendCommand("LSET mylist 10 four");
            // 
            var expectedResponse = "-ERR index out of range";
            var actualValue = Encoding.ASCII.GetString(response).Substring(0, expectedResponse.Length);
            Assert.AreEqual(expectedResponse, actualValue);

            response = lightClientRequest.SendCommand("LSET mylist -100 four");
            expectedResponse = "-ERR index out of range";
            actualValue = Encoding.ASCII.GetString(response).Substring(0, expectedResponse.Length);
            Assert.AreEqual(expectedResponse, actualValue);
        }

        [Test]
        public void CanReturnErrorLSETWhenArgumentsWrong()
        {
            using var lightClientRequest = TestUtils.CreateRequest();
            _ = lightClientRequest.SendCommand("RPUSH mylist one two three");
            var response = lightClientRequest.SendCommand("LSET mylist a");
            var expectedResponse = "-ERR wrong number of arguments for 'LSET'";
            var actualValue = Encoding.ASCII.GetString(response).Substring(0, expectedResponse.Length);