public void Test_E_DeleteQueue_And_Check_For_Valid_Response() { bool hasCallbackArrived = false; bool actualValue = false; bool expectedValue = true; SQSResponseEventHandler <object, ResponseEventArgs> handler = null; handler = delegate(object sender, ResponseEventArgs args) { ISQSResponse result = args.Response; //Unhook from event. _client.OnSQSResponse -= handler; DeleteQueueResponse response = result as DeleteQueueResponse; if (null != response) { actualValue = true; } hasCallbackArrived = true; }; //Hook to event _client.OnSQSResponse += handler; //Create request object. _client.DeleteQueue(new DeleteQueueRequest { QueueUrl = ((string.Format("{0}/{1}", QueueURL, _queue_UnitTesting_1))) }); EnqueueConditional(() => hasCallbackArrived); EnqueueCallback(() => Assert.IsTrue(expectedValue == actualValue)); EnqueueTestComplete(); }
public void Test_A_ListQueues_And_Check_For_NonNull_Response() { bool hasCallbackArrived = false; bool actualValue = false; bool expectedValue = true; SQSResponseEventHandler <object, ResponseEventArgs> handler = null; handler = delegate(object sender, ResponseEventArgs args) { ISQSResponse result = args.Response; //Unhook from event. _client.OnSQSResponse -= handler; ListQueuesResponse response = result as ListQueuesResponse; if (null != response) { actualValue = true; } hasCallbackArrived = true; }; //Hook to event _client.OnSQSResponse += handler; //Create request object. ListQueuesRequest listQueue = new ListQueuesRequest(); _client.ListQueues(listQueue); EnqueueConditional(() => hasCallbackArrived); EnqueueCallback(() => Assert.IsTrue(expectedValue == actualValue)); EnqueueTestComplete(); }
public void Test_CreateQueue_With_QueueName_Having_SpecialCharacters_And_Check_For_Error_Response() { bool hasCallbackArrived = false; string actualValue = string.Empty; string expectedValue = "InvalidParameterValue"; string queueNameWithSpecialChars = "queue&"; SQSResponseEventHandler <object, ResponseEventArgs> handler = null; handler = delegate(object sender, ResponseEventArgs args) { ISQSResponse result = args.Response; //Unhook from event. _client.OnSQSResponse -= handler; AmazonSQSException exception = result as AmazonSQSException; if (null != exception) { actualValue = exception.ErrorCode; } hasCallbackArrived = true; }; //Hook to event _client.OnSQSResponse += handler; //Create request object. _client.CreateQueue(new CreateQueueRequest { QueueName = queueNameWithSpecialChars }); EnqueueConditional(() => hasCallbackArrived); EnqueueCallback(() => Assert.IsTrue(expectedValue == actualValue)); EnqueueTestComplete(); }
public void SetUp() { _client = AWSClientFactory.CreateAmazonSQSClient(Access_Key_ID, Secret_Access_Key); //Ensure we create a test queue for the test cases. And remember to delete it in the teardown method. bool hasCallbackArrived = false; SQSResponseEventHandler <object, ResponseEventArgs> handler = null; handler = delegate(object sender, ResponseEventArgs args) { ISQSResponse result = args.Response; //Unhook from event. _client.OnSQSResponse -= handler; hasCallbackArrived = true; }; //Hook to event _client.OnSQSResponse += handler; _client.CreateQueue(new CreateQueueRequest { QueueName = _queue_UnitTesting, DefaultVisibilityTimeout = 3 }); EnqueueConditional(() => hasCallbackArrived); EnqueueTestComplete(); }
public void Test_ReceiveMessage_With_ValidQueue_And_Check_For_ReceivedMessage() { bool hasCallbackArrived = false; string actualValue = string.Empty; string expectedValue = "A test message body during Unit-Testing"; SQSResponseEventHandler <object, ResponseEventArgs> handler = null; handler = delegate(object sender, ResponseEventArgs args) { ISQSResponse result = args.Response; //Unhook from event. _client.OnSQSResponse -= handler; ReceiveMessageResponse response = result as ReceiveMessageResponse; if (null != response) { ReceiveMessageResult messageResult = response.ReceiveMessageResult; if (null != messageResult) { if (messageResult.Message.Count > 0) { Message message = messageResult.Message[0]; if (null != message) { actualValue = message.Body; } } } } hasCallbackArrived = true; }; //Hook to event _client.OnSQSResponse += handler; //Create request object. ReceiveMessageRequest request = new ReceiveMessageRequest { QueueUrl = (string.Format("{0}/{1}", QueueURL, _queue_UnitTesting)), }; _client.ReceiveMessage(request); EnqueueConditional(() => hasCallbackArrived); EnqueueCallback(() => Assert.IsTrue(string.Compare(expectedValue, actualValue) == 0)); EnqueueTestComplete(); }
public void Test_CreateQueue_With_Invalid_Attribute_And_Check_For_Valid_Response() { bool hasCallbackArrived = false; bool actualValue = false; bool expectedValue = true; SQSResponseEventHandler <object, ResponseEventArgs> handler = null; handler = delegate(object sender, ResponseEventArgs args) { ISQSResponse result = args.Response; //Unhook from event. _client.OnSQSResponse -= handler; CreateQueueResponse response = result as CreateQueueResponse; if (null != response) { if (null != response.CreateQueueResult) { actualValue = true; } } hasCallbackArrived = true; }; //Hook to event _client.OnSQSResponse += handler; //Create request object. CreateQueueRequest request = new CreateQueueRequest { QueueName = _queueWithInvalidAttributeName /*Attribute = new List<Amazon.SQS.Model.Attribute> { new Amazon.SQS.Model.Attribute { Name = "Hello", Value = "Test_Value" } } */ }; request.Attribute.Add(new Amazon.SQS.Model.Attribute { Name = "Hello", Value = "Test_Value" }); _client.CreateQueue(request); EnqueueConditional(() => hasCallbackArrived); EnqueueCallback(() => Assert.IsTrue(expectedValue == actualValue)); EnqueueTestComplete(); }
public void Test_GetQueueAttributes_And_Check_For_Valid_Value() { bool hasCallbackArrived = false; string actualValue = "-1"; string expectedValue = "3"; SQSResponseEventHandler <object, ResponseEventArgs> handler = null; handler = delegate(object sender, ResponseEventArgs args) { ISQSResponse result = args.Response; //Unhook from event. _client.OnSQSResponse -= handler; GetQueueAttributesResponse response = result as GetQueueAttributesResponse; if (null != response) { GetQueueAttributesResult attributeResult = response.GetQueueAttributesResult; if (null != attributeResult) { if (response.GetQueueAttributesResult.Attribute.Count > 0) { actualValue = response.GetQueueAttributesResult.Attribute[0].Value; } } } hasCallbackArrived = true; }; //Hook to event _client.OnSQSResponse += handler; //Create request object. GetQueueAttributesRequest request = new GetQueueAttributesRequest(); request.QueueUrl = string.Format("{0}/{1}", QueueURL, _queue_UnitTesting); request.AttributeName.Add("VisibilityTimeout"); _client.GetQueueAttributes(request); EnqueueConditional(() => hasCallbackArrived); EnqueueCallback(() => Assert.IsTrue(expectedValue == actualValue)); EnqueueTestComplete(); }
public void Test_A_SendMessage_And_Check_For_Valid_Response() { bool hasCallbackArrived = false; bool actualValue = false; bool expectedValue = true; string messageBody = "A test message body during Unit-Testing"; SQSResponseEventHandler <object, ResponseEventArgs> handler = null; handler = delegate(object sender, ResponseEventArgs args) { ISQSResponse result = args.Response; //Unhook from event. _client.OnSQSResponse -= handler; SendMessageResponse response = result as SendMessageResponse; if (null != response) { if (null != response.SendMessageResult) { actualValue = true; } } hasCallbackArrived = true; }; //Hook to event _client.OnSQSResponse += handler; //Create request object. SendMessageRequest request = new SendMessageRequest { QueueUrl = (string.Format("{0}/{1}", QueueURL, _queue_UnitTesting)), MessageBody = messageBody }; _client.SendMessage(request); EnqueueConditional(() => hasCallbackArrived); EnqueueCallback(() => Assert.IsTrue(expectedValue == actualValue)); EnqueueTestComplete(); }
public void Test_SendMessage_To_Queue_With_SpecialCharacters_And_Check_For_Error_Response() { bool hasCallbackArrived = false; string actualValue = string.Empty; string expectedValue = ""; string queueNameWithSpecialCharacters = "hello%"; string messageBody = "A test message body during Unit-Testing"; SQSResponseEventHandler <object, ResponseEventArgs> handler = null; handler = delegate(object sender, ResponseEventArgs args) { ISQSResponse result = args.Response; //Unhook from event. _client.OnSQSResponse -= handler; AmazonSQSException exception = result as AmazonSQSException; if (null != exception) { actualValue = exception.ErrorCode; } hasCallbackArrived = true; }; //Hook to event _client.OnSQSResponse += handler; //Create request object. SendMessageRequest request = new SendMessageRequest { QueueUrl = (string.Format("{0}/{1}", QueueURL, queueNameWithSpecialCharacters)), MessageBody = messageBody }; _client.SendMessage(request); EnqueueConditional(() => hasCallbackArrived); EnqueueCallback(() => Assert.IsTrue(expectedValue == actualValue)); EnqueueTestComplete(); }
public void Test_SendMessage_With_InvalidQueueURL_And_Check_For_Error_Response() { bool hasCallbackArrived = false; string actualValue = string.Empty; string expectedValue = "NotFound"; string expectedValue2 = "BadGateway"; string invalidQueueUrl = "https://queue.amazonawsabcdpoiu.com"; string messageBody = "A test message body during Unit-Testing"; SQSResponseEventHandler <object, ResponseEventArgs> handler = null; handler = delegate(object sender, ResponseEventArgs args) { ISQSResponse result = args.Response; //Unhook from event. _client.OnSQSResponse -= handler; AmazonSQSException exception = result as AmazonSQSException; if (null != exception) { actualValue = exception.StatusCode.ToString(); } hasCallbackArrived = true; }; //Hook to event _client.OnSQSResponse += handler; //Create request object. SendMessageRequest request = new SendMessageRequest { QueueUrl = (string.Format("{0}/{1}", invalidQueueUrl, _queue_UnitTesting)), MessageBody = messageBody }; _client.SendMessage(request); EnqueueConditional(() => hasCallbackArrived); EnqueueCallback(() => Assert.IsTrue((expectedValue == actualValue) || (expectedValue2 == actualValue))); EnqueueTestComplete(); }
public void Test_SetQueueAttributes_With_Multiple_Attributes_With_One_InvalidAttribute_And_Check_For_Error_Response() { bool hasCallbackArrived = false; string actualValue = string.Empty; string expectedValue = "InvalidAttributeName"; SQSResponseEventHandler <object, ResponseEventArgs> handler = null; handler = delegate(object sender, ResponseEventArgs args) { ISQSResponse result = args.Response; //Unhook from event. _client.OnSQSResponse -= handler; AmazonSQSException exception = result as AmazonSQSException; if (null != exception) { actualValue = exception.ErrorCode; } hasCallbackArrived = true; }; //Hook to event _client.OnSQSResponse += handler; //Create request object. SetQueueAttributesRequest request = new SetQueueAttributesRequest(); request.QueueUrl = string.Format("{0}/{1}", QueueURL, _queue_UnitTesting); request.Attribute.Add(new Amazon.SQS.Model.Attribute { Name = "VisibilityTimeout", Value = "3" }); request.Attribute.Add(new Amazon.SQS.Model.Attribute { Name = "invalidAttribute", Value = "6000" }); _client.SetQueueAttributes(request); EnqueueConditional(() => hasCallbackArrived); EnqueueCallback(() => Assert.IsTrue(string.Compare(expectedValue, actualValue) == 0)); EnqueueTestComplete(); }
public void Test_SetQueueAttributes_With_Multiple_Attributes_And_Check_For_Valid_Response() { bool hasCallbackArrived = false; bool actualValue = false; bool expectedValue = true; SQSResponseEventHandler <object, ResponseEventArgs> handler = null; handler = delegate(object sender, ResponseEventArgs args) { ISQSResponse result = args.Response; //Unhook from event. _client.OnSQSResponse -= handler; SetQueueAttributesResponse response = result as SetQueueAttributesResponse; if (null != response) { actualValue = true; } hasCallbackArrived = true; }; //Hook to event _client.OnSQSResponse += handler; //Create request object. SetQueueAttributesRequest request = new SetQueueAttributesRequest(); request.QueueUrl = string.Format("{0}/{1}", QueueURL, _queue_UnitTesting); request.Attribute.Add(new Amazon.SQS.Model.Attribute { Name = "VisibilityTimeout", Value = "3" }); request.Attribute.Add(new Amazon.SQS.Model.Attribute { Name = "MaximumMessageSize", Value = "6000" }); _client.SetQueueAttributes(request); EnqueueConditional(() => hasCallbackArrived); EnqueueCallback(() => Assert.IsTrue(expectedValue == actualValue)); EnqueueTestComplete(); }
public void Test_ReceiveMessage_With_NonExistingQueue_And_Check_For_Error_Response() { bool hasCallbackArrived = false; string actualValue = string.Empty; string expectedValue = "AWS.SimpleQueueService.NonExistentQueue"; string invalidQueueName = "InvalidQueueName_poiu"; SQSResponseEventHandler <object, ResponseEventArgs> handler = null; handler = delegate(object sender, ResponseEventArgs args) { ISQSResponse result = args.Response; //Unhook from event. _client.OnSQSResponse -= handler; AmazonSQSException exception = result as AmazonSQSException; if (null != exception) { actualValue = exception.ErrorCode; } hasCallbackArrived = true; }; //Hook to event _client.OnSQSResponse += handler; //Create request object. ReceiveMessageRequest request = new ReceiveMessageRequest { QueueUrl = (string.Format("{0}/{1}", QueueURL, invalidQueueName)), }; _client.ReceiveMessage(request); EnqueueConditional(() => hasCallbackArrived); EnqueueCallback(() => Assert.IsTrue(string.Compare(expectedValue, actualValue) == 0)); EnqueueTestComplete(); }
public void Test_C_CreateQueue_With_AlreadyExisting_Queue_Name_And_Check_For_Valid_Response() { bool hasCallbackArrived = false; bool actualValue = false; bool expectedValue = true; SQSResponseEventHandler <object, ResponseEventArgs> handler = null; handler = delegate(object sender, ResponseEventArgs args) { ISQSResponse result = args.Response; //Unhook from event. _client.OnSQSResponse -= handler; CreateQueueResponse response = result as CreateQueueResponse; if (null != response) { CreateQueueResult createResult = response.CreateQueueResult; if (null != createResult) { actualValue = true; } } hasCallbackArrived = true; }; //Hook to event _client.OnSQSResponse += handler; //Create request object. _client.CreateQueue(new CreateQueueRequest { QueueName = _queue_UnitTesting_1 }); EnqueueConditional(() => hasCallbackArrived); EnqueueCallback(() => Assert.IsTrue(expectedValue == actualValue)); EnqueueTestComplete(); }
public void Test_GetQueueAttributes_With_NonExisting_Attribute_And_Check_For_Error_Response() { bool hasCallbackArrived = false; string actualValue = string.Empty; string expectedValue = "InvalidAttributeName"; string nonExistingAttribute = "poiu"; SQSResponseEventHandler <object, ResponseEventArgs> handler = null; handler = delegate(object sender, ResponseEventArgs args) { ISQSResponse result = args.Response; //Unhook from event. _client.OnSQSResponse -= handler; AmazonSQSException exception = result as AmazonSQSException; if (null != exception) { actualValue = exception.ErrorCode; } hasCallbackArrived = true; }; //Hook to event _client.OnSQSResponse += handler; //Create request object. GetQueueAttributesRequest request = new GetQueueAttributesRequest(); request.QueueUrl = string.Format("{0}/{1}", QueueURL, _queue_UnitTesting); request.AttributeName.Add(nonExistingAttribute); _client.GetQueueAttributes(request); EnqueueConditional(() => hasCallbackArrived); EnqueueCallback(() => Assert.IsTrue(expectedValue == actualValue)); EnqueueTestComplete(); }
public ResponseEventArgs(ISQSResponse response) { this.Response = response; }