public void GivenValidMessageContentWhenSendingMessageToSingleRecipientThenTheMessageShouldBeDelivered() { PrepareTestEnvironment(Sender, HttpClientForSender); PrepareTestEnvironment(Recipient, HttpClientForRecipient); var sendMessageService = new SendDirectMessageService(new HttpMessagingService(HttpClientForSender)); var sendMessageParameters = new SendMessageParameters { OnboardResponse = Sender, ApplicationMessageId = MessageIdService.ApplicationMessageId(), TechnicalMessageType = TechnicalMessageTypes.ImgPng, Recipients = new List <string> { Recipient.SensorAlternateId }, Base64MessageContent = DataProvider.ReadBase64EncodedLargeBmp() }; sendMessageService.Send(sendMessageParameters); Thread.Sleep(TimeSpan.FromSeconds(5)); var fetchMessageService = new FetchMessageService(HttpClientForSender); var fetch = fetchMessageService.Fetch(Sender); Assert.Equal(6, fetch.Count); foreach (var messageResponse in fetch) { var decodedMessage = DecodeMessageService.Decode(messageResponse.Command.Message); Assert.Equal(201, decodedMessage.ResponseEnvelope.ResponseCode); } }
/// <summary> /// The actions for the sender are the following: /// 1. Send the message containing the image file. /// 2. Let the AR process the message for some seconds to be sure (this depends on the use case and is just an example /// time limit) /// 3. Fetch the message response and validate it. /// </summary> private static void ActionsForSender() { var sendMessageService = new SendDirectMessageService(new HttpMessagingService(HttpClientForSender)); var sendMessageParameters = new SendMessageParameters { OnboardResponse = Sender, ApplicationMessageId = MessageIdService.ApplicationMessageId(), TechnicalMessageType = TechnicalMessageTypes.ImgPng, Recipients = new List <string> { Recipient.SensorAlternateId }, Base64MessageContent = DataProvider.ReadBase64EncodedImage() }; sendMessageService.Send(sendMessageParameters); Thread.Sleep(TimeSpan.FromSeconds(2)); var fetchMessageService = new FetchMessageService(HttpClientForSender); var fetch = fetchMessageService.Fetch(Sender); Assert.Single(fetch); var decodedMessage = DecodeMessageService.Decode(fetch[0].Command.Message); Assert.Equal(201, decodedMessage.ResponseEnvelope.ResponseCode); }
public void GivenValidMessageContentWhenSendingMessageToSingleRecipientThenTheMessageShouldBeDelivered() { // Description of the messaging process. // 1. Set all capabilities for each endpoint - this is done once, not each time. SetCapabilitiesForSender(); SetCapabilitiesForRecipient(); // 2. Set routes within the UI - this is done once, not each time. // Done manually, not API interaction necessary. // 3. Send message from sender to recipient. var sendMessageService = new SendDirectMessageService(new HttpMessagingService(HttpClientForSender)); var sendMessageParameters = new SendMessageParameters { OnboardResponse = Sender, ApplicationMessageId = MessageIdService.ApplicationMessageId(), TechnicalMessageType = TechnicalMessageTypes.ImgPng, Recipients = new List <string> { Recipient.SensorAlternateId }, Base64MessageContent = DataProvider.ReadBase64EncodedImage() }; sendMessageService.Send(sendMessageParameters); // 4. Let the AR handle the message - this can take up to multiple seconds before receiving the ACK. Thread.Sleep(TimeSpan.FromSeconds(5)); // 5. Fetch and analyze the ACK from the AR. var fetchMessageService = new FetchMessageService(HttpClientForSender); var fetch = fetchMessageService.Fetch(Sender); Assert.Single(fetch); var decodedMessage = DecodeMessageService.Decode(fetch[0].Command.Message); Assert.Equal(201, decodedMessage.ResponseEnvelope.ResponseCode); }