Exemple #1
0
        public async Task CreateRESTSimulator()
        {
            var sim = GetSimulator(TransportTypes.RestHttp);

            sim.Simulator.Value.Anonymous = true;

            var runtime = new SimulatorRuntime(_runtimeServices.Object, _notifPublisher, _adminLogger, sim);

            var msg = new MessageTemplate()
            {
                Transport   = Core.Models.EntityHeader <TransportTypes> .Create(TransportTypes.RestHttp),
                PayloadType = Core.Models.EntityHeader <PaylodTypes> .Create(PaylodTypes.String),
                TextPayload = "abc123",
                EndPoint    = "www.software-logistics.com",
                Port        = 80,
                HttpVerb    = "GET"
            };

            var plan = new MessageTransmissionPlan()
            {
                Message = Core.Models.EntityHeader <MessageTemplate> .Create(msg)
            };


            var result = await runtime.SendAsync(plan);

            AssertSuccess(result);
        }
Exemple #2
0
        public async Task CreatAzureIoTHubSimulator()
        {
            var azIoTAccessKey = Environment.GetEnvironmentVariable("TEST_AZ_IOT_LISTENER_KEY");

            Assert.IsFalse(String.IsNullOrEmpty(azIoTAccessKey), "TEST_AZ_IOT_LISTENER_KEY");

            var azIoTAccountId = Environment.GetEnvironmentVariable("TEST_AZ_IOT_LISTENER_ACCOUNT_ID");

            Assert.IsFalse(String.IsNullOrEmpty(azIoTAccountId), "TEST_AZ_IOT_LISTENER_ACCOUNT_ID");

            var azIoTAccountPolicyName = Environment.GetEnvironmentVariable("TEST_AZ_IOT_LISTENER_POLICY_NAME");

            Assert.IsFalse(String.IsNullOrEmpty(azIoTAccountPolicyName), "TEST_AZ_IOT_LISTENER_POLICY_NAME");

            var ehCompatName = Environment.GetEnvironmentVariable("TEST_AZ_IOT_LISTENER_EH_COMPAT_NAME");

            Assert.IsFalse(String.IsNullOrEmpty(ehCompatName), "TEST_AZ_IOT_LISTENER_EH_COMPAT_NAME");

            var ehCompatEndPoint = Environment.GetEnvironmentVariable("TEST_AZ_IOT_LISTENER_EH_COMPAT_ENDPOINT");

            Assert.IsFalse(String.IsNullOrEmpty(ehCompatEndPoint), "TEST_AZ_IOT_LISTENER_EH_COMPAT_ENDPOINT");

            var azDeviceId = Environment.GetEnvironmentVariable("TEST_AZ_IOT_LISTENER_DEVICEID");

            Assert.IsFalse(String.IsNullOrEmpty(azDeviceId), "Missing TEST_AZ_IOT_LISTENER_DEVICEID");

            var sim = GetSimulator(TransportTypes.AzureIoTHub);

            sim.Simulator.Value.AccessKey     = azIoTAccessKey;
            sim.Simulator.Value.AccessKeyName = azIoTAccountPolicyName;

            var msg = new MessageTemplate()
            {
                Transport   = Core.Models.EntityHeader <TransportTypes> .Create(TransportTypes.RestHttp),
                PayloadType = Core.Models.EntityHeader <PaylodTypes> .Create(PaylodTypes.String),
                TextPayload = "abc123",
                EndPoint    = "www.software-logistics.com",
                Port        = 80,
                HttpVerb    = "GET"
            };


            var plan = new MessageTransmissionPlan()
            {
                Message = Core.Models.EntityHeader <MessageTemplate> .Create(msg)
            };

            var runtime = new SimulatorRuntime(_runtimeServices.Object, _notifPublisher, _adminLogger, sim);

            var result = await runtime.SendAsync(plan);

            AssertSuccess(result);
        }
Exemple #3
0
        public async Task CreateMQTTSimulator()
        {
            var testHostName = Environment.GetEnvironmentVariable("TEST_MQTT_HOST_NAME");

            Assert.IsFalse(String.IsNullOrEmpty(testHostName), "Missing environment variable TEST_MQTT_HOST_NAME");

            var testUserName = Environment.GetEnvironmentVariable("TEST_MQTT_USER_NAME");

            Assert.IsFalse(String.IsNullOrEmpty(testUserName), "Missing environment variable TEST_MQTT_USER_NAME");

            var testPwd = Environment.GetEnvironmentVariable("TEST_MQTT_PASSWORD");

            Assert.IsFalse(String.IsNullOrEmpty(testPwd), "Missing environment variable TEST_MQTT_PASSWORD");

            var sim = GetSimulator(TransportTypes.MQTT);

            sim.Simulator.Value.DefaultEndPoint = testHostName;
            sim.Simulator.Value.DefaultPort     = 1883;
            sim.Simulator.Value.UserName        = testUserName;
            sim.Simulator.Value.Password        = testPwd;

            var msg = new MessageTemplate()
            {
                PayloadType = Core.Models.EntityHeader <PaylodTypes> .Create(PaylodTypes.String),
                Topic       = "sendit",
                TextPayload = "abc123",
            };

            var runtime = new SimulatorRuntime(_runtimeServices.Object, _notifPublisher, _adminLogger, sim);

            var connectResult = await runtime.ConnectAsync();

            AssertSuccess(connectResult);

            var plan = new MessageTransmissionPlan()
            {
                Message = Core.Models.EntityHeader <MessageTemplate> .Create(msg)
            };

            var result = await runtime.SendAsync(plan);

            AssertSuccess(result);

            var disconnectResult = await runtime.DisconnectAsync();

            AssertSuccess(disconnectResult);
        }
Exemple #4
0
        public async Task CreateSBSimulator()
        {
            var sbTrasnamitterKey = Environment.GetEnvironmentVariable("TEST_SB_ACCESSKEY");

            Assert.IsFalse(String.IsNullOrEmpty(sbTrasnamitterKey));

            var accountId = System.Environment.GetEnvironmentVariable("TEST_SB_ACCOUNT_ID");

            Assert.IsFalse(String.IsNullOrEmpty(accountId), "TEST_SB_ACCOUNT_ID");

            var sbPolicyName = System.Environment.GetEnvironmentVariable("TEST_SB_POLICY_NAME");

            Assert.IsFalse(String.IsNullOrEmpty(sbPolicyName), "TEST_SB_POLICY_NAME");

            var sim = GetSimulator(TransportTypes.AzureServiceBus);

            var msg = new MessageTemplate()
            {
                Transport   = Core.Models.EntityHeader <TransportTypes> .Create(TransportTypes.RestHttp),
                PayloadType = Core.Models.EntityHeader <PaylodTypes> .Create(PaylodTypes.String),
                TextPayload = "abc123",
                EndPoint    = "www.software-logistics.com",
                Port        = 80,
                HttpVerb    = "GET"
            };


            var plan = new MessageTransmissionPlan()
            {
                Message = Core.Models.EntityHeader <MessageTemplate> .Create(msg)
            };

            var runtime = new SimulatorRuntime(_runtimeServices.Object, _notifPublisher, _adminLogger, sim);

            var result = await runtime.SendAsync(plan);

            AssertSuccess(result);
        }