public async Task ProcessRemoveDesiredPropertiesUpdateSubscription() { // Arrange var edgeHub = new Mock <IEdgeHub>(); edgeHub.Setup(e => e.RemoveSubscription("d1", DeviceSubscription.DesiredPropertyUpdates)) .Returns(Task.CompletedTask); var connMgr = Mock.Of <IConnectionManager>(); var identity = Mock.Of <IDeviceIdentity>(i => i.Id == "d1"); var deviceProxy = new Mock <IDeviceProxy>(); IMessage sentMessage = null; deviceProxy.Setup(d => d.SendTwinUpdate(It.IsAny <IMessage>())) .Callback <IMessage>(m => sentMessage = m) .Returns(Task.CompletedTask); var listener = new DeviceMessageHandler(identity, edgeHub.Object, connMgr, DefaultMessageAckTimeout, Option.None <string>()); listener.BindDeviceProxy(deviceProxy.Object); string correlationId = Guid.NewGuid().ToString(); // Act await listener.RemoveDesiredPropertyUpdatesSubscription(correlationId); // Assert Assert.NotNull(sentMessage); Assert.Equal(correlationId, sentMessage.SystemProperties[SystemProperties.CorrelationId]); Assert.Equal("200", sentMessage.SystemProperties[SystemProperties.StatusCode]); edgeHub.VerifyAll(); }