public async Task CreateQueueWithErrorAsync() { var rsmq = new Rsmq(); Assert.ThrowsAsync <MissingParameterException>(async() => await rsmq.CreateQueueAsync(new CreateQueueOptions { QueueName = null })); Assert.ThrowsAsync <InvalidFormatException>(async() => await rsmq.CreateQueueAsync(new CreateQueueOptions { QueueName = Global.WrongQueueNameFormat })); var queues = await rsmq.ListQueuesAsync(); Assert.Zero(queues.Count()); }
public async Task ReceiveMessageAsync() { var rsmq = new Rsmq(); await rsmq.CreateQueueAsync(new CreateQueueOptions { QueueName = Global.QueueName }); var msgId1 = await rsmq.SendMessageAsync(new SendMessageOptions { QueueName = Global.QueueName, Message = "hello1" }); var msgId2 = await rsmq.SendMessageAsync(new SendMessageOptions { QueueName = Global.QueueName, Message = "hello2" }); var message1 = await rsmq.ReceiveMessageAsync(new ReceiveMessageOptions { QueueName = Global.QueueName }); var message2 = await rsmq.ReceiveMessageAsync(new ReceiveMessageOptions { QueueName = Global.QueueName }); Assert.NotNull(message1); Assert.NotNull(message2); Assert.AreEqual("hello1", message1.Message); Assert.AreEqual("hello2", message2.Message); Assert.AreEqual(msgId1, message1.Id); Assert.AreEqual(msgId2, message2.Id); Assert.AreEqual(1, await rsmq.DeleteMessageAsync(new DeleteMessageOptions { QueueName = Global.QueueName, Id = msgId1 })); Assert.AreEqual(1, await rsmq.DeleteMessageAsync(new DeleteMessageOptions { QueueName = Global.QueueName, Id = msgId2 })); }
public async Task DeleteQueueAsync() { var rsmq = new Rsmq(); await rsmq.CreateQueueAsync(new CreateQueueOptions { QueueName = Global.QueueName }); Assert.AreEqual(1, (await rsmq.ListQueuesAsync()).Count()); await rsmq.DeleteQueueAsync(new DeleteQueueOptions { QueueName = Global.QueueName }); Assert.Zero((await rsmq.ListQueuesAsync()).Count()); }
public async Task CreateQueueAsync(string value) { var rsmq = new Rsmq(); Assert.AreEqual(1, await rsmq.CreateQueueAsync(new CreateQueueOptions { QueueName = value })); var queues = await rsmq.ListQueuesAsync(); Assert.Contains(value, queues.ToArray()); }
public async Task DeleteMessageAsync() { var rsmq = new Rsmq(); await rsmq.CreateQueueAsync(new CreateQueueOptions { QueueName = Global.QueueName }); var msgId = await rsmq.SendMessageAsync(new SendMessageOptions { QueueName = Global.QueueName, Message = "hello" }); Assert.AreEqual(1, await rsmq.DeleteMessageAsync(new DeleteMessageOptions { QueueName = Global.QueueName, Id = msgId })); Assert.Zero(await rsmq.DeleteMessageAsync(new DeleteMessageOptions { QueueName = Global.QueueName, Id = "0123456789abcdefghijklmnopqrstuv" })); }
public async Task ListQueuesAsync() { var rsmq = new Rsmq(); var queues = await rsmq.ListQueuesAsync(); Assert.Zero(queues.Count()); await rsmq.CreateQueueAsync(new CreateQueueOptions { QueueName = Global.QueueName }); queues = await rsmq.ListQueuesAsync(); Assert.AreEqual(queues.Count(), 1); Assert.Contains(Global.QueueName, queues.ToArray()); }
public async Task PopMessageAsync() { var rsmq = new Rsmq(); await rsmq.CreateQueueAsync(new CreateQueueOptions { QueueName = Global.QueueName }); var msgId = await rsmq.SendMessageAsync(new SendMessageOptions { QueueName = Global.QueueName, Message = "hello" }); var poppedMessage = await rsmq.PopMessageAsync(new PopMessageOptions { QueueName = Global.QueueName }); Assert.AreEqual(msgId, poppedMessage.Id); Assert.Zero(await rsmq.DeleteMessageAsync(new DeleteMessageOptions { QueueName = Global.QueueName, Id = msgId })); }
public async Task ChangeMessageVisibilityAsync() { var rsmq = new Rsmq(); await rsmq.CreateQueueAsync(new CreateQueueOptions { QueueName = Global.QueueName }); var msgId = await rsmq.SendMessageAsync(new SendMessageOptions { QueueName = Global.QueueName, Message = "hello" }); await rsmq.ChangeMessageVisibilityAsync(new ChangeMessageVisibilityOptions { QueueName = Global.QueueName, Id = msgId, VisibilityTimer = 2 }); Assert.IsNull(await rsmq.ReceiveMessageAsync(new ReceiveMessageOptions { QueueName = Global.QueueName })); await Task.Delay(2500); Assert.IsNotNull(await rsmq.ReceiveMessageAsync(new ReceiveMessageOptions { QueueName = Global.QueueName })); }
public async Task GetQueueAttributesAsync(CreateQueueOptions value) { var rsmq = new Rsmq(); await rsmq.CreateQueueAsync(value); var attributes = await rsmq.GetQueueAttributesAsync(new GetQueueAttributesOptions { QueueName = value.QueueName }); Assert.AreEqual(attributes.Delay, value.Delay); Assert.AreEqual(attributes.MaxSize, value.MaxSize); Assert.AreEqual(attributes.VisibilityTimer, value.VisibilityTimer); Assert.AreEqual(0, attributes.TotalSent); await rsmq.SendMessageAsync(new SendMessageOptions { QueueName = value.QueueName, Message = "Halo" }); attributes = await rsmq.GetQueueAttributesAsync(new GetQueueAttributesOptions { QueueName = value.QueueName }); Assert.AreEqual(1, attributes.TotalSent); }
public async Task SetQueueAttributesWithErrorAsync() { var rsmq = new Rsmq(); Assert.ThrowsAsync <QueueNotFoundException>(async() => await rsmq.SetQueueAttributesAsync(new SetQueueAttributesOptions { QueueName = Global.QueueName, MaxSize = 7453 })); await rsmq.CreateQueueAsync(new CreateQueueOptions { QueueName = Global.QueueName }); Assert.ThrowsAsync <QueueNotFoundException>(async() => await rsmq.SetQueueAttributesAsync(new SetQueueAttributesOptions { QueueName = Global.WrongQueueName, MaxSize = 3000 })); Assert.ThrowsAsync <NoAttributeSuppliedException>(async() => await rsmq.SetQueueAttributesAsync(new SetQueueAttributesOptions { QueueName = Global.QueueName })); Assert.ThrowsAsync <InvalidValueException>(async() => await rsmq.SetQueueAttributesAsync(new SetQueueAttributesOptions { QueueName = Global.QueueName, MaxSize = -34 })); }
public async Task SetQueueAttributesAsync(SetQueueAttributesOptions value) { var rsmq = new Rsmq(); var defaultAttributes = new CreateQueueOptions { QueueName = value.QueueName }; await rsmq.CreateQueueAsync(defaultAttributes); var queueAttributes = await rsmq.GetQueueAttributesAsync(new GetQueueAttributesOptions { QueueName = value.QueueName }); Assert.AreEqual(defaultAttributes.Delay, queueAttributes.Delay); Assert.AreEqual(defaultAttributes.MaxSize, queueAttributes.MaxSize); Assert.AreEqual(defaultAttributes.VisibilityTimer, queueAttributes.VisibilityTimer); queueAttributes = await rsmq.SetQueueAttributesAsync(value); Assert.AreEqual(value.Delay ?? defaultAttributes.Delay, queueAttributes.Delay); Assert.AreEqual(value.MaxSize ?? defaultAttributes.MaxSize, queueAttributes.MaxSize); Assert.AreEqual(value.VisibilityTimer ?? defaultAttributes.VisibilityTimer, queueAttributes.VisibilityTimer); }