private static void RunWith(OnboardResponse onboardResponse) { var httpClient = HttpClientFactory.AuthenticatedHttpClient(onboardResponse); var capabilitiesServices = new CapabilitiesService(new HttpMessagingService(httpClient)); var capabilitiesParameters = new CapabilitiesParameters { OnboardResponse = onboardResponse, ApplicationId = ApplicationId, CertificationVersionId = CertificationVersionId, EnablePushNotifications = CapabilitySpecification.Types.PushNotification.Disabled, CapabilityParameters = new List <CapabilityParameter>() }; var capabilitiesParameter = new CapabilityParameter { Direction = CapabilitySpecification.Types.Direction.SendReceive, TechnicalMessageType = TechnicalMessageTypes.Iso11783TaskdataZip }; capabilitiesParameters.CapabilityParameters.Add(capabilitiesParameter); capabilitiesServices.Send(capabilitiesParameters); Thread.Sleep(TimeSpan.FromSeconds(5)); var fetchMessageService = new FetchMessageService(httpClient); var fetch = fetchMessageService.Fetch(onboardResponse); Assert.Single(fetch); var decodedMessage = DecodeMessageService.Decode(fetch[0].Command.Message); Assert.Equal(201, decodedMessage.ResponseEnvelope.ResponseCode); }
private static void PrepareTestEnvironmentForRecipient() { var capabilitiesServices = new CapabilitiesService(new HttpMessagingService(HttpClientForRecipient)); var capabilitiesParameters = new CapabilitiesParameters { OnboardResponse = Recipient, ApplicationId = ApplicationId, CertificationVersionId = CertificationVersionId, EnablePushNotifications = CapabilitySpecification.Types.PushNotification.Disabled, CapabilityParameters = new List <CapabilityParameter>() }; var capabilitiesParameter = new CapabilityParameter { Direction = CapabilitySpecification.Types.Direction.SendReceive, TechnicalMessageType = TechnicalMessageTypes.ImgPng }; capabilitiesParameters.CapabilityParameters.Add(capabilitiesParameter); capabilitiesServices.Send(capabilitiesParameters); Thread.Sleep(TimeSpan.FromSeconds(2)); var fetchMessageService = new FetchMessageService(HttpClientForRecipient); var fetch = fetchMessageService.Fetch(Recipient); Assert.Single(fetch); var decodedMessage = DecodeMessageService.Decode(fetch[0].Command.Message); Assert.Equal(201, decodedMessage.ResponseEnvelope.ResponseCode); }
public void GivenValidCapabilitiesWhenSendingCapabilitiesMessageThenTheAgrirouterShouldSetTheCapabilities() { var capabilitiesServices = new CapabilitiesService(new HttpMessagingService(HttpClient)); var capabilitiesParameters = new CapabilitiesParameters { OnboardResponse = OnboardResponse, ApplicationId = ApplicationId, CertificationVersionId = CertificationVersionId, EnablePushNotifications = CapabilitySpecification.Types.PushNotification.Disabled, CapabilityParameters = new List <CapabilityParameter>() }; var capabilitiesParameter = new CapabilityParameter { Direction = CapabilitySpecification.Types.Direction.SendReceive, TechnicalMessageType = TechnicalMessageTypes.Iso11783TaskdataZip }; capabilitiesParameters.CapabilityParameters.Add(capabilitiesParameter); capabilitiesServices.Send(capabilitiesParameters); Thread.Sleep(TimeSpan.FromSeconds(5)); var fetchMessageService = new FetchMessageService(HttpClient); var fetch = fetchMessageService.Fetch(OnboardResponse); Assert.Single(fetch); var decodedMessage = DecodeMessageService.Decode(fetch[0].Command.Message); Assert.Equal(201, decodedMessage.ResponseEnvelope.ResponseCode); }
GivenValidCapabilitiesWhenSendingCapabilitiesMessageThenTheAgrirouterShouldSetTheCapabilities() { var mqttClient = new MqttFactory().CreateMqttClient(); await MqttConnectionHelper.ConnectMqttClient(mqttClient, OnboardResponse); await MqttConnectionHelper.SubscribeToTopics(mqttClient, OnboardResponse); var capabilitiesServices = new CapabilitiesService(new MqttMessagingService(mqttClient)); var capabilitiesParameters = new CapabilitiesParameters { OnboardResponse = OnboardResponse, ApplicationId = ApplicationId, CertificationVersionId = CertificationVersionId, EnablePushNotifications = CapabilitySpecification.Types.PushNotification.Disabled, CapabilityParameters = new List <CapabilityParameter>() }; var capabilitiesParameter = new CapabilityParameter { Direction = CapabilitySpecification.Types.Direction.SendReceive, TechnicalMessageType = TechnicalMessageTypes.Iso11783TaskdataZip }; capabilitiesParameters.CapabilityParameters.Add(capabilitiesParameter); capabilitiesServices.Send(capabilitiesParameters); var messageReceived = false; var counter = 0; mqttClient.UseApplicationMessageReceivedHandler(e => { messageReceived = true; var messagePayload = Encoding.UTF8.GetString(e.ApplicationMessage.Payload); var decodedMessage = DecodeMessageService.Decode(messagePayload); Assert.Equal(201, decodedMessage.ResponseEnvelope.ResponseCode); }); while (!messageReceived && counter < 5) { await Task.Delay(TimeSpan.FromSeconds(5)); counter++; } Assert.True(messageReceived); }