public void TestCachingCreatesAFile()
		{
			using (var client = new QueueClient())
			{
				var homemadeTask = new TaskMessage
				{
					Parameters = "params",
					Queue = "TestQueue"
				};

				client.Enqueue(homemadeTask);
				var retrievedTask = client.Reserve("TestQueue");

				Assert.That(File.Exists("redisCache.bin"));

				client.Fail(string.Empty);
				client.RemoveTask(client.AllTasks("TestQueue")[0]);
			}
		}
        public void TestCachingCreatesAFile()
        {
            using (var client = new QueueClient())
            {
                var homemadeTask = new TaskMessage
                {
                    Parameters = "params",
                    Queue      = "TestQueue"
                };

                client.Enqueue(homemadeTask);
                var retrievedTask = client.Reserve("TestQueue");

                Assert.That(File.Exists("redisCache.bin"));

                client.Fail(string.Empty);
                client.RemoveTask(client.AllTasks("TestQueue")[0]);
            }
        }
		public void TestCanEnqueueTaskInRedisAndReadItBack()
		{
			using(var client = new QueueClient())
			{
				var homemadeTask = new TaskMessage
				{
					Parameters = "params", 
					Queue = "TestQueue"
				};

				client.Enqueue(homemadeTask);
				var retrievedTask = client.Reserve("TestQueue");
			
				Assert.AreEqual(retrievedTask.Parameters, homemadeTask.Parameters);
				Assert.AreEqual(retrievedTask.Queue, homemadeTask.Queue);

				client.Fail(string.Empty);
				client.RemoveTask(client.AllTasks("TestQueue")[0]);
			}
		}
        public void TestCanEnqueueTaskInRedisAndReadItBack()
        {
            using (var client = new QueueClient())
            {
                var homemadeTask = new TaskMessage
                {
                    Parameters = "params",
                    Queue      = "TestQueue"
                };

                client.Enqueue(homemadeTask);
                var retrievedTask = client.Reserve("TestQueue");

                Assert.AreEqual(retrievedTask.Parameters, homemadeTask.Parameters);
                Assert.AreEqual(retrievedTask.Queue, homemadeTask.Queue);

                client.Fail(string.Empty);
                client.RemoveTask(client.AllTasks("TestQueue")[0]);
            }
        }
        public void TestCachingCanPreserveTask()
        {
            using (var client = new QueueClient())
            {
                var homemadeTask = new TaskMessage
                {
                    Parameters = "params",
                    Queue      = "TestQueue"
                };

                client.Enqueue(homemadeTask);
                var retrievedTask = client.Reserve("TestQueue");
            }

            using (var client = new QueueClient())
            {
                Assert.That(client.CurrentTask != null);
                client.Fail(string.Empty);
                client.RemoveTask(client.AllTasks("TestQueue")[0]);
            }
        }
        public void TestCantReserveMultipleTasksAtOnce()
        {
            using (var client = new QueueClient())
            {
                client.Enqueue(new TaskMessage
                {
                    Parameters = "params",
                    Queue      = "TestQueue"
                });

                client.Enqueue(new TaskMessage
                {
                    Parameters = "params",
                    Queue      = "TestQueue"
                });

                client.Reserve("TestQueue");
                Assert.Throws <TaskAlreadyReservedException>(() => client.Reserve("TestQueue"));

                client.Fail(string.Empty);
                client.RemoveTask(client.AllTasks("TestQueue")[0]);
                client.RemoveTask(client.AllTasks("TestQueue")[0]);
            }
        }
        public void TestCantReserveMultipleTasksAtOnce()
        {
            using (var client = new QueueClient())
            {
                client.Enqueue(new TaskMessage
                {
                    Parameters = "params",
                    Queue = "TestQueue"
                });

                client.Enqueue(new TaskMessage
                {
                    Parameters = "params",
                    Queue = "TestQueue"
                });

                client.Reserve("TestQueue");
                Assert.Throws<TaskAlreadyReservedException>(() => client.Reserve("TestQueue"));

                client.Fail(string.Empty);
                client.RemoveTask(client.AllTasks("TestQueue")[0]);
                client.RemoveTask(client.AllTasks("TestQueue")[0]);
            }
        }
        public void TestCachingCanPreserveTask()
        {
            using (var client = new QueueClient())
            {
                var homemadeTask = new TaskMessage
                {
                    Parameters = "params",
                    Queue = "TestQueue"
                };

                client.Enqueue(homemadeTask);
                var retrievedTask = client.Reserve("TestQueue");
            }

            using (var client = new QueueClient())
            {
                Assert.That(client.CurrentTask != null);
                client.Fail(string.Empty);
                client.RemoveTask(client.AllTasks("TestQueue")[0]);
            }
        }