Example #1
0
        public void TryParsePrimitive(object instance, bool isSuccess, object value)
        {
            var success = RedisValueExtractor.TryParsePrimitive(instance, out RedisValue result);

            Assert.AreEqual(isSuccess, success);
            Assert.AreEqual((RedisValue)(string)value, result);
        }
Example #2
0
        private RedisValue GetValue(T instance)
        {
            if (!RedisValueExtractor.TryParsePrimitive(instance, out RedisValue redisValue))
            {
                return(serializer.Serialize(instance));
            }

            return(redisValue);
        }
Example #3
0
        public void TryParsePrimitiveComplex()
        {
            var success = RedisValueExtractor.TryParsePrimitive <int?>(1, out RedisValue result);

            Assert.AreEqual(true, success);
            Assert.AreEqual((RedisValue)1, result);

            success = RedisValueExtractor.TryParsePrimitive <int?>(null, out result);
            Assert.AreEqual(true, success);
            Assert.AreEqual(RedisValue.Null, result);
        }