public void Cannot_sent_a_message_to_a_non_existent_queue() { var sqs = new InMemorySqsClient(); var sent = AwsSqsMessage.FromBody("foo"); try { sqs.Send("bar", sent, new Result<AwsSqsSendResponse>()).Wait(); Assert.Fail("didn't throw"); } catch(AwsSqsRequestException e) { Assert.AreEqual("AWS.SimpleQueueService.NonExistentQueue", e.Error.Code); } }
public void Can_round_trip_message_through_queue() { var sqs = new InMemorySqsClient(); sqs.CreateQueue("bar", new Result<AwsSqsResponse>()).Wait(); var sent = AwsSqsMessage.FromBody("foo"); sqs.Send("bar", sent, new Result<AwsSqsSendResponse>()).Wait(); var msgs = sqs.Receive("bar", new Result<IEnumerable<AwsSqsMessage>>()).Wait(); Assert.AreEqual(1, msgs.Count()); var received = msgs.First(); Assert.AreEqual(sent.Body, received.Body); }
public void Can_delete_message_from_queue() { var sqs = new InMemorySqsClient(); sqs.CreateQueue("bar", new Result<AwsSqsResponse>()).Wait(); var sent = AwsSqsMessage.FromBody("foo"); sqs.Send("bar", sent, new Result<AwsSqsSendResponse>()).Wait(); var received = sqs.Receive("bar", 10, TimeSpan.Zero, new Result<IEnumerable<AwsSqsMessage>>()).Wait().First(); sqs.Delete(received, new Result<AwsSqsResponse>()).Wait(); var remaining = sqs.Receive("bar", 10, TimeSpan.Zero, new Result<IEnumerable<AwsSqsMessage>>()).Wait(); Assert.IsFalse(remaining.Any()); }
public void Sending_to_non_existent_queue_sets_exception_in_result() { var sqs = new InMemorySqsClient(); var r = sqs.Send("foo", AwsSqsMessage.FromBody("foo"), new Result<AwsSqsSendResponse>()).Block(); Assert.IsTrue(r.HasException); }
public void Can_see_messages_with_visibility_zero() { var sqs = new InMemorySqsClient(); sqs.CreateQueue("bar", new Result<AwsSqsResponse>()).Wait(); var sent = sqs.Send("bar", AwsSqsMessage.FromBody("foo"), new Result<AwsSqsSendResponse>()).Wait(); var received1 = sqs.Receive("bar", 10, TimeSpan.Zero, new Result<IEnumerable<AwsSqsMessage>>()).Wait(); var received2 = sqs.Receive("bar", 10, TimeSpan.Zero, new Result<IEnumerable<AwsSqsMessage>>()).Wait(); Assert.AreEqual(1,received1.Count()); Assert.AreEqual(1, received2.Count()); Assert.AreEqual(sent.MessageId, received1.First().MessageId); Assert.AreEqual(sent.MessageId, received2.First().MessageId); }