Esempio n. 1
0
        public async Task DirectMethodCallForwarded()
        {
            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 request = new DirectMethodRequest("123", "name", new byte[] { 1, 2, 3 }, TimeSpan.FromSeconds(60));

            Mock.Get(directMethodHandler)
            .Setup(h => h.CallDirectMethodAsync(It.Is <DirectMethodRequest>(m => m == request), It.Is <IIdentity>(i => i == identity)))
            .Returns(Task.FromResult(new DirectMethodResponse("123", new byte[0], 200)));

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

            await sut.InvokeMethodAsync(request);

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