Esempio n. 1
0
        public async Task TwinUpdatesForwarded()
        {
            var twinHandler         = Mock.Of <ITwinHandler>();
            var m2mHandler          = Mock.Of <IModuleToModuleMessageHandler>();
            var c2dHandler          = Mock.Of <ICloud2DeviceMessageHandler>();
            var directMethodHandler = Mock.Of <IDirectMethodHandler>();
            var identity            = new DeviceIdentity("hub", "device_id");

            var twin = new EdgeMessage.Builder(new byte[0]).Build();

            Mock.Get(twinHandler)
            .Setup(h => h.SendTwinUpdate(It.Is <IMessage>(m => m == twin), It.Is <IIdentity>(i => i == identity)))
            .Returns(Task.CompletedTask);

            var sut = new DeviceProxy(identity, twinHandler, m2mHandler, c2dHandler, directMethodHandler);

            await sut.SendTwinUpdate(twin);

            Mock.Get(directMethodHandler).VerifyAll();
        }
Esempio n. 2
0
        public async Task EdgeHubIsIndirect()
        {
            var connectionHandler   = Mock.Of <IConnectionRegistry>();
            var twinHandler         = Mock.Of <ITwinHandler>();
            var m2mHandler          = Mock.Of <IModuleToModuleMessageHandler>();
            var c2dHandler          = Mock.Of <ICloud2DeviceMessageHandler>();
            var directMethodHandler = Mock.Of <IDirectMethodHandler>();
            var identity            = new ModuleIdentity("hub", "device_id", "$edgeHub");

            var twin = new EdgeMessage.Builder(new byte[0]).Build();

            Mock.Get(twinHandler)
            .Setup(h => h.SendTwinUpdate(It.IsAny <IMessage>(), It.Is <IIdentity>(i => i == identity), It.Is <bool>(d => d == false)))
            .Returns(Task.CompletedTask);

            var sut = new DeviceProxy(identity, true, connectionHandler, twinHandler, m2mHandler, c2dHandler, directMethodHandler);

            await sut.SendTwinUpdate(twin);

            Mock.Get(twinHandler).VerifyAll();
        }