public async Task ForwardsGetTwinOperationToEdgeHub() { var edgeHub = new Mock <IEdgeHub>(); var connMgr = Mock.Of <IConnectionManager>(); var identity = Mock.Of <IDeviceIdentity>(i => i.Id == "d1"); var cloudProxy = Mock.Of <ICloudProxy>(); var deviceProxy = new Mock <IDeviceProxy>(); IMessage actualMessage = null; deviceProxy.Setup(d => d.SendTwinUpdate(It.IsAny <IMessage>())) .Callback <IMessage>(m => actualMessage = m) .Returns(Task.CompletedTask); IMessage expectedMessage = new EdgeMessage.Builder(new byte[0]).Build(); edgeHub.Setup(e => e.GetTwinAsync(It.IsAny <string>())).Returns(Task.FromResult(expectedMessage)); Mock.Get(connMgr).Setup(c => c.GetCloudConnection(It.IsAny <string>())).Returns(Task.FromResult(Option.Some(cloudProxy))); var listener = new DeviceMessageHandler(identity, edgeHub.Object, connMgr, DefaultMessageAckTimeout, Option.None <string>()); listener.BindDeviceProxy(deviceProxy.Object); await listener.SendGetTwinRequest("cid"); edgeHub.Verify(x => x.GetTwinAsync(identity.Id), Times.Once); Assert.Same(expectedMessage, actualMessage); }