Exemplo n.º 1
0
        private async Task InitDeviceAsync()
        {
            await pnpClient.ReportPropertyAsync("serialNumber", serialNumber);

            await pnpClient.ReportComponentPropertyCollectionAsync("deviceInfo", DeviceInfo.ThisDeviceInfo.ToDictionary());

            var targetTemp1 = await pnpClient.ReadDesiredComponentPropertyAsync <double>("thermostat1", "targetTemperature");

            CurrentTemperature1 = targetTemp1;
            var targetTemp2 = await pnpClient.ReadDesiredComponentPropertyAsync <double>("thermostat2", "targetTemperature");

            CurrentTemperature2 = targetTemp2;
        }
Exemplo n.º 2
0
        public async Task ComponentReportPropertyCollection()
        {
            var props = new Dictionary <string, object>
            {
                { "prop1", "val1" },
                { "prop2", "val2" }
            };
            await pnpClient.ReportComponentPropertyCollectionAsync("c1", props);

            var compTwinValue1 = mockClient.ReportedCollection.GetPropertyValue <string>("c1", "prop1");

            Assert.Equal("val1", compTwinValue1);
            var compTwinValue2 = mockClient.ReportedCollection.GetPropertyValue <string>("c1", "prop2");

            Assert.Equal("val2", compTwinValue2);
        }