示例#1
0
        public void SetBinaryValue()
        {
            string key = RedisProviderUnitTests.GetTempRedisKey();

            this.QueueableOperation.SetValue(key, Encoding.UTF8.GetBytes("Hello"));

            this.CompleteOperation();

            Assert.AreEqual("Hello", Encoding.UTF8.GetString(this.Provider.GetBinaryValue(key)));
        }
示例#2
0
        public void RollbackOnDispose()
        {
            string key = RedisProviderUnitTests.GetTempRedisKey();

            this.QueueableOperation.SetValue(key, "A");

            this.QueueableOperation.Dispose();

            Assert.IsFalse(this.Provider.ContainsKey(key));
        }
示例#3
0
        public void SetTextValueNullValue()
        {
            string key = RedisProviderUnitTests.GetTempRedisKey();

            this.QueueableOperation.SetValue(key, (string)null);

            this.CompleteOperation();

            Assert.IsTrue(string.IsNullOrEmpty(this.Provider.GetTextValue(key)));
        }
示例#4
0
        public void SetHashBinaryValueEmptyField()
        {
            string key = RedisProviderUnitTests.GetTempRedisKey();

            this.QueueableOperation.SetHashValue(key, string.Empty, Encoding.ASCII.GetBytes("Value"));

            this.CompleteOperation();

            Assert.AreEqual("Value", Encoding.ASCII.GetString(this.Provider.GetHashBinaryValue(key, string.Empty)));
        }
示例#5
0
        public void SetHashTextValueEmptyField()
        {
            string key = RedisProviderUnitTests.GetTempRedisKey();

            this.QueueableOperation.SetHashValue(key, string.Empty, "Value");

            this.CompleteOperation();

            Assert.AreEqual("Value", this.Provider.GetHashTextValue(key, string.Empty));
        }
示例#6
0
        public void SetHashTextValue()
        {
            string key = RedisProviderUnitTests.GetTempRedisKey();

            this.QueueableOperation.SetHashValue(key, "Hello", "World");

            this.CompleteOperation();

            Assert.AreEqual("World", this.Provider.GetHashTextValue(key, "Hello"));
        }
示例#7
0
        public void SetHashBinaryValue()
        {
            string key = RedisProviderUnitTests.GetTempRedisKey();

            this.QueueableOperation.SetHashValue(key, "Hello", Encoding.ASCII.GetBytes("World"));

            this.CompleteOperation();

            byte[] content = this.Provider.GetHashBinaryValue(key, "Hello");

            Assert.AreEqual("World", Encoding.ASCII.GetString(content));
        }
示例#8
0
        public void SetBinaryValueNullValue()
        {
            string key = RedisProviderUnitTests.GetTempRedisKey();

            this.QueueableOperation.SetValue(key, (byte[])null);

            this.CompleteOperation();

            byte[] result = this.Provider.GetBinaryValue(key);

            Assert.IsTrue((result == null) || (result.Length == 0));
        }
示例#9
0
        public void RemoveKey()
        {
            string key = RedisProviderUnitTests.GetTempRedisKey();

            this.Provider.SetValue(key, "Hello");

            this.QueueableOperation.RemoveKey(key);

            this.CompleteOperation();

            Assert.IsNull(this.Provider.GetTextValue(key));
        }
示例#10
0
        public void Commit()
        {
            string key1 = RedisProviderUnitTests.GetTempRedisKey();
            string key2 = RedisProviderUnitTests.GetTempRedisKey();

            this.QueueableOperation.SetValue(key1, "A");
            this.QueueableOperation.SetValue(key2, "B");

            this.QueueableOperation.Commit();

            Assert.AreEqual("A", this.Provider.GetTextValue(key1));
            Assert.AreEqual("B", this.Provider.GetTextValue(key2));
        }
示例#11
0
        public void GetTextValue()
        {
            string key = RedisProviderUnitTests.GetTempRedisKey();

            this.Provider.SetValue(key, "Hello");

            string value = null;

            this.QueueableOperation.GetTextValue(key, v => value = v);

            this.CompleteOperation();

            Assert.AreEqual("Hello", value);
        }
示例#12
0
        public void AddToList()
        {
            string key = RedisProviderUnitTests.GetTempRedisKey();

            this.QueueableOperation.AddToList(key, "A");
            this.QueueableOperation.AddToList(key, "B");

            this.CompleteOperation();

            IEnumerable <string> actualValues = this.Provider.GetListAsText(key);

            Assert.AreEqual(2, actualValues.Count());

            Assert.IsTrue(actualValues.Contains("A"));
            Assert.IsTrue(actualValues.Contains("B"));
        }
示例#13
0
        public void RemoveFromHashNoFields()
        {
            string key = RedisProviderUnitTests.GetTempRedisKey();

            this.Provider.SetHashValue(key, "A", "1");

            this.QueueableOperation.RemoveFromHash(key);

            this.CompleteOperation();

            var result = this.Provider.GetHashAsText(key);

            Assert.AreEqual(1, result.Count());

            Assert.IsTrue(result.ContainsKey("A"));
        }
示例#14
0
        public void RemoveFromSet()
        {
            string key = RedisProviderUnitTests.GetTempRedisKey();

            this.Provider.AddToSet(key, "A");
            this.Provider.AddToSet(key, "B");

            this.QueueableOperation.RemoveFromSet(key, "A");

            this.CompleteOperation();

            IEnumerable <string> actualValues = this.Provider.GetSet(key);

            Assert.AreEqual(1, actualValues.Count());

            Assert.IsFalse(actualValues.Contains("A"));
            Assert.IsTrue(actualValues.Contains("B"));
        }
示例#15
0
        public void PopFirstListElementAsBinary()
        {
            string key = RedisProviderUnitTests.GetTempRedisKey();

            this.Provider.AddToList(key, Encoding.ASCII.GetBytes("A"));
            this.Provider.AddToList(key, Encoding.ASCII.GetBytes("B"));

            byte[] result1 = null, result2 = null, result3 = null;

            this.QueueableOperation.PopFirstListElementAsBinary(key, v => result1 = v);
            this.QueueableOperation.PopFirstListElementAsBinary(key, v => result2 = v);
            this.QueueableOperation.PopFirstListElementAsBinary(key, v => result3 = v);

            this.CompleteOperation();

            Assert.AreEqual("A", Encoding.ASCII.GetString(result1));
            Assert.AreEqual("B", Encoding.ASCII.GetString(result2));
            Assert.IsNull(result3);
        }
示例#16
0
        public void PopFirstListElementAsText()
        {
            string key = RedisProviderUnitTests.GetTempRedisKey();

            this.Provider.AddToList(key, "A");
            this.Provider.AddToList(key, "B");

            string result1 = null, result2 = null, result3 = null;

            this.QueueableOperation.PopFirstListElementAsText(key, v => result1 = v);
            this.QueueableOperation.PopFirstListElementAsText(key, v => result2 = v);
            this.QueueableOperation.PopFirstListElementAsText(key, v => result3 = v);

            this.CompleteOperation();

            Assert.AreEqual("A", result1);
            Assert.AreEqual("B", result2);
            Assert.IsTrue(string.IsNullOrEmpty(result3));
        }
示例#17
0
        public void SetHashValuesBinary()
        {
            Dictionary <string, byte[]> expectedValues = new Dictionary <string, byte[]>();

            expectedValues.Add("A", Encoding.ASCII.GetBytes("1"));
            expectedValues.Add("B", Encoding.ASCII.GetBytes("2"));

            string key = RedisProviderUnitTests.GetTempRedisKey();

            this.QueueableOperation.SetHashValues(key, expectedValues);

            this.CompleteOperation();

            IReadOnlyDictionary <string, byte[]> actualValues = this.Provider.GetHashAsBinary(key);

            Assert.IsNotNull(actualValues);

            Assert.AreEqual(2, actualValues.Count);

            Assert.AreEqual("1", Encoding.ASCII.GetString(actualValues["A"]));
            Assert.AreEqual("2", Encoding.ASCII.GetString(actualValues["B"]));
        }
示例#18
0
        public void SetHashValuesText()
        {
            Dictionary <string, string> expectedValues = new Dictionary <string, string>();

            expectedValues.Add("A", "1");
            expectedValues.Add("B", "2");

            string key = RedisProviderUnitTests.GetTempRedisKey();

            this.QueueableOperation.SetHashValues(key, expectedValues);

            this.CompleteOperation();

            IReadOnlyDictionary <string, string> actualValues = this.Provider.GetHashAsText(key);

            Assert.IsNotNull(actualValues);

            Assert.AreEqual(2, actualValues.Count);

            Assert.AreEqual("1", actualValues["A"]);
            Assert.AreEqual("2", actualValues["B"]);
        }