Exemplo n.º 1
0
        public async Task ReportedPropertyUpdatesAsTelemetryTest()
        {
            var routes = new List <string>
            {
                @"FROM /* INTO $upstream",
            };

            string edgeDeviceId = "edge";
            var    iotHub       = new IoTHub();

            (IEdgeHub edgeHub, IConnectionManager connectionManager) = await SetupEdgeHub(routes, iotHub, edgeDeviceId);

            TestDevice device1 = await TestDevice.Create("device1", edgeHub, connectionManager);

            IMessage message = GetReportedPropertiesMessage();
            await device1.UpdateReportedProperties(message);

            await Task.Delay(GetSleepTime());

            Assert.True(iotHub.HasReceivedTwinChangeNotification(edgeDeviceId, edgeHubModuleId));
        }
Exemplo n.º 2
0
        public async Task TestRoutingTwinChangeNotificationFromModule()
        {
            var routes = new List <string>
            {
                @"FROM /twinChangeNotifications INTO BrokeredEndpoint(""/modules/mod1/inputs/in1"")"
            };

            string edgeDeviceId = "edge";
            var    iotHub       = new IoTHub();

            (IEdgeHub edgeHub, IConnectionManager connectionManager) = await SetupEdgeHub(routes, iotHub, edgeDeviceId);

            TestModule module1 = await TestModule.Create(edgeDeviceId, "mod1", "op1", "in1", edgeHub, connectionManager);

            TestModule module2 = await TestModule.Create(edgeDeviceId, "mod2", "op2", "in2", edgeHub, connectionManager);

            IMessage message = GetReportedPropertiesMessage();
            await module2.UpdateReportedProperties(message);

            await Task.Delay(GetSleepTime());

            Assert.True(iotHub.HasReceivedTwinChangeNotification());
            Assert.True(module1.HasReceivedTwinChangeNotification());
        }