Example #1
0
        public async Task NoComponentSetDesiredPropertyHandler()
        {
            string valueReaded = string.Empty;
            await nocomp.SetPnPDesiredPropertyHandlerAsync <string>("prop1", (object newValue) =>
            {
                valueReaded = newValue.ToString();
            }, this);

            TwinCollection desired = new TwinCollection(@"{prop1: 'val1'}");
            await mockClient.DesiredPropertyUpdateCallback(desired, this);

            Assert.Equal("val1", valueReaded);
            var reported = mockClient.ReportedCollection;

            Assert.Equal("{\"prop1\":{\"value\":\"val1\",\"ac\":200,\"av\":0,\"ad\":\"update complete\"}}", reported.ToJson());
        }
        public async Task ComponentSetDesiredPropertyHandler()
        {
            string valueReaded = string.Empty;

            pnpClient.SetDesiredPropertyUpdateCommandHandler("c1", (TwinCollection newValue) =>
            {
                valueReaded = newValue.ToJson();
            });

            TwinCollection desired = new TwinCollection(@"{ c1: {prop1: 'val1'}}");
            await mockClient.DesiredPropertyUpdateCallback(desired, this);

            Assert.Equal("{\"c1\":{\"prop1\":\"val1\"}}", valueReaded);
        }