本文整理汇总了C#中QueueClient.Reserve方法的典型用法代码示例。如果您正苦于以下问题:C# QueueClient.Reserve方法的具体用法?C# QueueClient.Reserve怎么用?C# QueueClient.Reserve使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QueueClient
的用法示例。
在下文中一共展示了QueueClient.Reserve方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestCachingCreatesAFile
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]);
}
}
示例2: TestCanEnqueueTaskInRedisAndReadItBack
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]);
}
}
示例3: TestReserveThrowsExceptionWhenQueueIsEmpty
public void TestReserveThrowsExceptionWhenQueueIsEmpty()
{
using (var client = new QueueClient())
Assert.Throws<QueueIsEmptyException>(() => client.Reserve("TestQueue"));
}
示例4: TestReserveThrowsExceptionWhenPassedAnEmptyStringAsQueue
public void TestReserveThrowsExceptionWhenPassedAnEmptyStringAsQueue()
{
using (var client = new QueueClient())
Assert.Throws<InvalidQueueNameException>(() => client.Reserve(string.Empty));
}
示例5: TestCantReserveMultipleTasksAtOnce
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]);
}
}
示例6: TestEmptyQueueThrowsException
public void TestEmptyQueueThrowsException()
{
using (var client = new QueueClient())
Assert.Throws<QueueIsEmptyException>(() => client.Reserve("messages"));
}
示例7: TestCachingCanPreserveTask
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]);
}
}