Esempio n. 1
0
        public void RedisValuePushException()
        {
            var host   = "wronghost";
            var port   = "6379";
            var prefix = "";
            var connectionInformation = new Kalfoni.Redis.ConnectionInformation(host, port, prefix);

            var redisValue = new RedisValue();
            var stackName  = "TestStackPushException";
            var redisKey   = new RedisKey();


            string json = @"{
                            'Name': 'Bad Boys',
                            'ReleaseDate': '1995-4-7T00:00:00',
                            'Genres': [
                                'Action',
                                'Comedy'
                                 ]
                           }";

            redisValue = json;
            redisKey   = stackName;

            Assert.Throws <Exception>(() => Kalfoni.Redis.Stack.Push(connectionInformation, redisValue, redisKey));
        }
Esempio n. 2
0
        public void StringSet_StringGetTest3()
        {
            var host   = "localhost";
            var port   = "6379";
            var prefix = "";
            var connectionInformation = new Kalfoni.Redis.ConnectionInformation(host, port, prefix);

            var keyName = "StringSet_StringGetTest2";



            string json = @"{
                            'Name': 'Bad Boys',
                            'ReleaseDate': '1995-4-7T00:00:00',
                            'Genres': [
                                'Action',
                                'Comedy'
                                 ]
                           }";

            var result = Kalfoni.Redis.General.StringSet(connectionInformation, json, keyName, 3000, General.TimeUnit.Milliseconds);

            Assert.True(result);

            var result2 = Kalfoni.Redis.General.StringGet(connectionInformation, keyName);

            Assert.Equal(json, result2);
        }
Esempio n. 3
0
        public void StringSet_ExceptionTest1()
        {
            var host   = "wronghost";
            var port   = "6379";
            var prefix = "";
            var connectionInformation = new Kalfoni.Redis.ConnectionInformation(host, port, prefix);

            var redisValue = new RedisValue();
            var keyName    = "StringSet_StringGetTest1";
            var redisKey   = new RedisKey();


            string json = @"{
                            'Name': 'Bad Boys',
                            'ReleaseDate': '1995-4-7T00:00:00',
                            'Genres': [
                                'Action',
                                'Comedy'
                                 ]
                           }";

            redisValue = json;
            redisKey   = keyName;

            Assert.Throws <Exception>(() => Kalfoni.Redis.General.StringSet(connectionInformation, redisValue, redisKey, 1));
        }
Esempio n. 4
0
        public void StringSet_StringGetTest1()
        {
            var host   = "localhost";
            var port   = "6379";
            var prefix = "";
            var connectionInformation = new Kalfoni.Redis.ConnectionInformation(host, port, prefix);

            var redisValue = new RedisValue();
            var keyName    = "StringSet_StringGetTest1";
            var redisKey   = new RedisKey();


            string json = @"{
                            'Name': 'Bad Boys',
                            'ReleaseDate': '1995-4-7T00:00:00',
                            'Genres': [
                                'Action',
                                'Comedy'
                                 ]
                           }";

            redisValue = json;
            redisKey   = keyName;

            var result = Kalfoni.Redis.General.StringSet(connectionInformation, redisValue, redisKey, 1);

            Assert.True(result);

            var result2 = Kalfoni.Redis.General.StringGet(connectionInformation, redisKey);

            Assert.Equal(json, result2);
        }
Esempio n. 5
0
        public void StringSet_ExceptionTest3()
        {
            var host   = "wronghost";
            var port   = "6379";
            var prefix = "";
            var connectionInformation = new Kalfoni.Redis.ConnectionInformation(host, port, prefix);
            var keyName = "StringSet_StringGetTest2";

            Assert.Throws <Exception>(() => Kalfoni.Redis.General.StringGet(connectionInformation, keyName));
        }
Esempio n. 6
0
        public void ConnectionInformationTest1()
        {
            var host   = "localhost";
            var port   = "6379";
            var prefix = "";
            var connectionInformation = new Kalfoni.Redis.ConnectionInformation(host, port, prefix);

            Assert.Equal(connectionInformation.Host, host);
            Assert.Equal(connectionInformation.Port, port);
            Assert.Equal(connectionInformation.KeyPrefix, prefix);
        }
Esempio n. 7
0
        public void ListLengthException()
        {
            var host   = "wronghost";
            var port   = "6379";
            var prefix = "";
            var connectionInformation = new Kalfoni.Redis.ConnectionInformation(host, port, prefix);

            var stackName = "TestStackQueueListLengthException";
            var redisKey  = new RedisKey();

            redisKey = stackName;

            Assert.Throws <Exception>(() => Kalfoni.Redis.Stack_Queue_Common.ListLength(connectionInformation, redisKey));
        }
Esempio n. 8
0
        public void RedisValuePopException()
        {
            var host   = "wronghost";
            var port   = "6379";
            var prefix = "";
            var connectionInformation = new Kalfoni.Redis.ConnectionInformation(host, port, prefix);

            var stackName = "TestStackPopException";
            var redisKey  = new RedisKey();


            redisKey = stackName;

            Assert.Throws <Exception>(() => Kalfoni.Redis.Stack.Pop(connectionInformation, redisKey));
        }
Esempio n. 9
0
        public async void ConnectionInformationTest5Async()
        {
            var RedisConnectionInformation = new Kalfoni.Redis.ConnectionInformation("localhost", "6379", "Lumen_" + "Test");

            RedisConnectionInformation.AbortOnConnectFailValue = true;
            RedisConnectionInformation.ConnectionTimeoutValue  = 5;
            RedisConnectionInformation.SyncTimeoutValue        = 1;

            Assert.NotNull(RedisConnectionInformation.LazyConnection);
            Assert.Equal("localhost", RedisConnectionInformation.Host);
            Assert.Equal("6379", RedisConnectionInformation.Port);
            Assert.Equal("Lumen_Test", RedisConnectionInformation.KeyPrefix);
            Assert.Equal(5, RedisConnectionInformation.ConnectionTimeoutValue);
            Assert.Equal(1, RedisConnectionInformation.SyncTimeoutValue);
            Assert.True(RedisConnectionInformation.AbortOnConnectFailValue);
        }
Esempio n. 10
0
        public void PushPopTest1()
        {
            var host   = "localhost";
            var port   = "6379";
            var prefix = "";
            var connectionInformation = new Kalfoni.Redis.ConnectionInformation(host, port, prefix);

            var redisValue = new RedisValue();
            var stackName  = "TestStack1";
            var redisKey   = new RedisKey();


            string json = @"{
                            'Name': 'Bad Boys',
                            'ReleaseDate': '1995-4-7T00:00:00',
                            'Genres': [
                                'Action',
                                'Comedy'
                                 ]
                           }";

            redisValue = json;
            redisKey   = stackName;


            var count = Queue.ListLength(connectionInformation, stackName);

            Assert.Equal(0, Convert.ToInt32(count));

            var result = Stack.Push(connectionInformation, redisValue, redisKey);

            Assert.True(result);

            count = Queue.ListLength(connectionInformation, stackName);
            Assert.Equal(1, Convert.ToInt32(count));


            var stackResult = Stack.Pop(connectionInformation, (RedisKey)stackName);

            Assert.True(result);
        }
Esempio n. 11
0
        public void ConnectionInformationTest6()
        {
            var redisConnectionInformation = new Kalfoni.Redis.ConnectionInformation();

            redisConnectionInformation.Host      = "localhost";
            redisConnectionInformation.Port      = "6379";
            redisConnectionInformation.KeyPrefix = "Lumen_Test";
            redisConnectionInformation.ConnectionTimeoutValue  = 6;
            redisConnectionInformation.SyncTimeoutValue        = 4;
            redisConnectionInformation.AbortOnConnectFailValue = true;

            redisConnectionInformation.CreateConnection();

            Assert.NotNull(redisConnectionInformation.LazyConnection);
            Assert.Equal("localhost", redisConnectionInformation.Host);
            Assert.Equal("6379", redisConnectionInformation.Port);
            Assert.Equal("Lumen_Test", redisConnectionInformation.KeyPrefix);
            Assert.Equal(6, redisConnectionInformation.ConnectionTimeoutValue);
            Assert.Equal(4, redisConnectionInformation.SyncTimeoutValue);
            Assert.True(redisConnectionInformation.AbortOnConnectFailValue);
        }
Esempio n. 12
0
        public void EnqueueDequeueTest2()
        {
            var host   = "localhost";
            var port   = "6379";
            var prefix = "";
            var connectionInformation = new Kalfoni.Redis.ConnectionInformation(host, port, prefix);

            var redisValue = new RedisValue();
            var stackName  = "TestQueue2";

            string json = @"{
                            'Name': 'Bad Boys',
                            'ReleaseDate': '1995-4-7T00:00:00',
                            'Genres': [
                                'Action',
                                'Comedy'
                                 ]
                           }";

            redisValue = json;



            var count = Queue.ListLength(connectionInformation, stackName);

            Assert.Equal(0, Convert.ToInt32(count));

            var result = Queue.Enqueue(connectionInformation, json, stackName);

            Assert.True(result);

            count = Queue.ListLength(connectionInformation, stackName);
            Assert.Equal(1, Convert.ToInt32(count));

            var queueRresult = Queue.Dequeue(connectionInformation, stackName);

            Assert.True(result);
        }