本文整理汇总了C#中QueueServiceClient类的典型用法代码示例。如果您正苦于以下问题:C# QueueServiceClient类的具体用法?C# QueueServiceClient怎么用?C# QueueServiceClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
QueueServiceClient类属于命名空间,在下文中一共展示了QueueServiceClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateQueue_ValidName_CreatesQueue
public void CreateQueue_ValidName_CreatesQueue()
{
IQueueServiceClient client = new QueueServiceClient(_accountSettings);
var queueName = GenerateSampleQueueName();
client.CreateQueue(queueName);
_util.AssertQueueExists(queueName);
}
示例2: CreateQueue_AlreadyExistsWithNoMetadata_ReportsNoContentPerDocumentation
public void CreateQueue_AlreadyExistsWithNoMetadata_ReportsNoContentPerDocumentation()
{
IQueueServiceClient client = new QueueServiceClient(_accountSettings);
var queueName = GenerateSampleQueueName();
_util.CreateQueue(queueName);
client.CreateQueue(queueName);
// I don't think I can/should-be-able-to test the return code at this level...
}
示例3: ListQueues_AtLeastOneQueue_ReturnsListContainingThatQueue
public void ListQueues_AtLeastOneQueue_ReturnsListContainingThatQueue()
{
IQueueServiceClient client = new QueueServiceClient(_accountSettings);
var queueName = GenerateSampleQueueName();
_util.CreateQueue(queueName);
var response = client.ListQueues();
Assert.IsTrue(response.Queues.Any(q => q.Name == queueName));
}
示例4: PutMessage_TooLargeMessage_ThrowsRequestBodyTooLargeException
public void PutMessage_TooLargeMessage_ThrowsRequestBodyTooLargeException()
{
IQueueServiceClient client = new QueueServiceClient(_accountSettings);
var queueName = GenerateSampleQueueName();
_util.CreateQueue(queueName);
string message = new String('a', 64 * 1024 + 1);
client.PutMessage(queueName, message);
//expects exception
}
示例5: CreateQueue_ValidNameAndMetadata_CreatesQueue
public void CreateQueue_ValidNameAndMetadata_CreatesQueue()
{
IQueueServiceClient client = new QueueServiceClient(_accountSettings);
var queueName = GenerateSampleQueueName();
client.CreateQueue(queueName, new Dictionary<string, string>() {
{ "SampleName", "SampleValue" }
});
_util.AssertQueueExists(queueName);
}
示例6: PutMessage_ValidMessage_AddsMessageToQueue
public void PutMessage_ValidMessage_AddsMessageToQueue()
{
IQueueServiceClient client = new QueueServiceClient(_accountSettings);
var queueName = GenerateSampleQueueName();
_util.CreateQueue(queueName);
string message = "Unit Test Message";
client.PutMessage(queueName, message);
_util.AssertQueueHasMessage(queueName);
}
示例7: PutMessage_InvalidXMLCharacters_DoesNotThrowException
public void PutMessage_InvalidXMLCharacters_DoesNotThrowException()
{
IQueueServiceClient client = new QueueServiceClient(_accountSettings);
var queueName = GenerateSampleQueueName();
_util.CreateQueue(queueName);
string message = "{\"KeyValueLogPayload\": {\"UserIP\": \"::1\",\"URL\": \"http://fakeurl/foo?bar=baz&baz=bar\"}}";
Assert.DoesNotThrow(() =>
{
client.PutMessage(queueName, message);
});
}
示例8: CreateQueue_AlreadyExistsWithMatchingMetadata_ReportsNoContentPerDocumentation
public void CreateQueue_AlreadyExistsWithMatchingMetadata_ReportsNoContentPerDocumentation()
{
IQueueServiceClient client = new QueueServiceClient(_accountSettings);
var queueName = GenerateSampleQueueName();
_util.CreateQueue(queueName, new Dictionary<string, string> {
{ "SampleKey", "SampleValue" }
});
client.CreateQueue(queueName, new Dictionary<string, string> {
{ "SampleKey", "SampleValue" }
});
// I don't think I can/should-be-able-to test the return code at this level...
}
示例9: ListQueues_MaxResultsSmallerThanQueueList_ReturnsOnlyThatManyResults
public void ListQueues_MaxResultsSmallerThanQueueList_ReturnsOnlyThatManyResults()
{
IQueueServiceClient client = new QueueServiceClient(_accountSettings);
var queueNames = new List<string>();
for (int i = 0; i < 5; i++)
{
var queueName = GenerateSampleQueueName(i.ToString());
_util.CreateQueue(queueName);
queueNames.Add(queueName);
}
var response = client.ListQueues(maxResults: 3);
Assert.AreEqual(3, response.Queues.Count);
}
示例10: ListQueues_WithPrefix_ReturnsListContainingOnlyQueuesWithThatPrefix
public void ListQueues_WithPrefix_ReturnsListContainingOnlyQueuesWithThatPrefix()
{
IQueueServiceClient client = new QueueServiceClient(_accountSettings);
var queueNames = new List<string>();
for (int i = 18; i < 21; i++)
{
var queueName = GenerateSampleQueueName(i.ToString());
_util.CreateQueue(queueName);
queueNames.Add(queueName);
}
var response = client.ListQueues("1");
Assert.AreEqual("1", response.Prefix);
Assert.IsTrue(response.Queues.Count(q => q.Name.StartsWith("1")) >= 2);
Assert.AreEqual(0, response.Queues.Count(q => !q.Name.StartsWith("1")));
}
示例11: UpdateMessage_InvalidXMLMessageTextCharacters_DoesNotThrowException
public void UpdateMessage_InvalidXMLMessageTextCharacters_DoesNotThrowException()
{
const string rawFirstText = "<QueueMessage><MessageText>Test</MessageText></QueueMessage>";
const string rawSecondText = "{\"KeyValueLogPayload\": {\"UserIP\": \"::1\",\"URL\": \"http://fakeurl/foo?bar=baz&baz=bar\"}}";
IQueueServiceClient client = new QueueServiceClient(_accountSettings);
var queueName = GenerateSampleQueueName();
_util.CreateQueue(queueName);
_util.AddItemsToQueue(queueName, new List<string>() { rawFirstText });
var itemFromQueue = _util.GetItemFromQueue(queueName, 1);
Assert.DoesNotThrow(() =>
{
client.UpdateMessage(queueName, itemFromQueue.Id, itemFromQueue.PopReceipt, 0, rawSecondText);
});
}
示例12: UpdateMessage_DifferentMessageText_ChangesMessageText
public void UpdateMessage_DifferentMessageText_ChangesMessageText()
{
const string rawFirstText = "1";
const string rawSecondText = "2";
var firstText = Convert.ToBase64String(Encoding.UTF8.GetBytes(rawFirstText));
var secondText = Convert.ToBase64String(Encoding.UTF8.GetBytes(rawSecondText));
IQueueServiceClient client = new QueueServiceClient(_accountSettings);
var queueName = GenerateSampleQueueName();
_util.CreateQueue(queueName);
_util.AddItemsToQueue(queueName, new List<string>() { firstText });
var itemFromQueue = _util.GetItemFromQueue(queueName, 1);
client.UpdateMessage(queueName, itemFromQueue.Id, itemFromQueue.PopReceipt, 0, secondText);
var itemFromQueueAgain = _util.GetItemFromQueue(queueName);
Assert.AreEqual(rawSecondText, itemFromQueueAgain.AsString);
}
示例13: UpdateMessage_ExtendVisibility_ExtendsMessageVisibilityInTheQueue
public void UpdateMessage_ExtendVisibility_ExtendsMessageVisibilityInTheQueue()
{
IQueueServiceClient client = new QueueServiceClient(_accountSettings);
var queueName = GenerateSampleQueueName();
_util.CreateQueue(queueName);
_util.AddItemsToQueue(queueName, new List<string>() { "1" });
var itemFromQueue = _util.GetItemFromQueue(queueName, 1);
var response = client.UpdateMessage(queueName, itemFromQueue.Id, itemFromQueue.PopReceipt, 30);
Assert.IsNotNullOrEmpty(response.PopReceipt);
Thread.Sleep(2000); // longer than the original visibility timeout
var itemFromQueueAgain = _util.GetItemFromQueue(queueName);
Assert.IsNull(itemFromQueueAgain);
}
示例14: UpdateMessage_UpdateContent_UpdatesContentOfMessageInQueue
public void UpdateMessage_UpdateContent_UpdatesContentOfMessageInQueue()
{
IQueueServiceClient client = new QueueServiceClient(_accountSettings);
var queueName = GenerateSampleQueueName();
_util.CreateQueue(queueName);
_util.AddItemsToQueue(queueName, new List<string>() { "1" });
var itemFromQueue = _util.GetItemFromQueue(queueName);
var newString = Convert.ToBase64String(Encoding.ASCII.GetBytes("2")); // the official SDK base 64's the values automatically
client.UpdateMessage(queueName, itemFromQueue.Id, itemFromQueue.PopReceipt, 0, newString);
var itemFromQueueAgain = _util.GetItemFromQueue(queueName);
Assert.IsNotNull(itemFromQueueAgain);
Assert.AreEqual(itemFromQueue.Id, itemFromQueueAgain.Id);
Assert.AreEqual("1", itemFromQueue.AsString);
Assert.AreEqual("2", itemFromQueueAgain.AsString);
}
示例15: ClearMessagesAsync_QueueDoesNotExist_ThrowsQueueNotFoundException
public async Task ClearMessagesAsync_QueueDoesNotExist_ThrowsQueueNotFoundException()
{
IQueueServiceClient client = new QueueServiceClient(_accountSettings);
var queueName = GenerateSampleQueueName();
await client.ClearMessagesAsync(queueName);
//expects exception
}