Ejemplo n.º 1
0
        public async Task TestRemoveExistingQueue()
        {
            using (TCacheService cache = new TCacheService(TestConfiguration.EnvRedisUri))
            {
                await cache.PushToQueue(TestRemoveQueue, new List <Cat> {
                    new Cat {
                        Name = "Kel", Age = 12
                    }
                });

                await cache.RemoveQueue(TestRemoveQueue);

                bool result = await cache.QueueExists(TestRemoveQueue);

                Assert.False(result);
            }
        }
Ejemplo n.º 2
0
        public async Task GetQueue()
        {
            TCacheService cache = new TCacheService(TestConfiguration.EnvRedisUri);
            await cache.PushToQueue(TestQueueName, new List <Cat> {
                new Cat {
                    Name = "NotDead", Age = 3
                }
            });

            Cat cat1 = await cache.PopFromQueue <Cat>(TestQueueName, TCachePopMode.Get);

            Cat cat2 = await cache.PopFromQueue <Cat>(TestQueueName, TCachePopMode.Get);

            bool done = cat1.Name == "NotDead" && cat2.Name == "NotDead";

            // make sure the queue is empty
            Cat cat3 = await cache.PopFromQueue <Cat>(TestQueueName, TCachePopMode.Delete);

            Cat cat4 = await cache.PopFromQueue <Cat>(TestQueueName, TCachePopMode.Delete);

            if (cat3 != null)
            {
                Console.WriteLine(cat3.Name);
            }

            if (cat4 != null)
            {
                Console.WriteLine(cat4.Name);
            }

            done = done && cat3 != null && cat4 == null;

            // remove the queue
            await cache.RemoveQueue(TestQueueName);

            // result
            Assert.True(done);
        }
Ejemplo n.º 3
0
 public async Task <bool> RemoveQueue(string queueName)
 {
     return(await _cacheService.RemoveQueue(queueName));
 }