Beispiel #1
0
        public void TestSetAsync_RemovedSubscription_ShouldComplete()
        {
            var           edgeHub         = new Mock <IEdgeHub>();
            var           identity        = Mock.Of <IProtocolgatewayDeviceIdentity>(i => i.Id == "d1");
            var           sessionProvider = new SessionStatePersistenceProvider(edgeHub.Object);
            ISessionState sessionState    = new SessionState(false);

            sessionState.RemoveSubscription(SessionStatePersistenceProvider.MethodSubscriptionTopicPrefix);
            Task setTask = sessionProvider.SetAsync(identity, sessionState);

            Assert.True(setTask.IsCompleted);
            edgeHub.Verify(x => x.RemoveSubscription("d1", DeviceSubscription.Methods), Times.Once);
        }
Beispiel #2
0
        public void TestSetAsync_SetMultipleSubscriptions_ShouldComplete()
        {
            var edgeHub         = new Mock <IEdgeHub>();
            var identity        = Mock.Of <IProtocolgatewayDeviceIdentity>(i => i.Id == "d1");
            var sessionProvider = new SessionStatePersistenceProvider(edgeHub.Object);

            ISessionState sessionState = new SessionState(false);

            sessionState.AddOrUpdateSubscription(SessionStatePersistenceProvider.MethodSubscriptionTopicPrefix, QualityOfService.AtLeastOnce);
            sessionState.AddOrUpdateSubscription(SessionStatePersistenceProvider.TwinResponseTopicFilter, QualityOfService.AtLeastOnce);
            Task setTask = sessionProvider.SetAsync(identity, sessionState);

            Assert.True(setTask.IsCompleted);
            edgeHub.Verify(x => x.AddSubscription("d1", DeviceSubscription.Methods), Times.Once);
        }
        public void TestSetAsync_AddedMethodSubscription_ShouldComplete()
        {
            var           edgeHub         = new Mock <IEdgeHub>();
            var           identity        = Mock.Of <IProtocolgatewayDeviceIdentity>(i => i.Id == "d1");
            var           sessionProvider = new SessionStatePersistenceProvider(edgeHub.Object);
            ISessionState sessionState    = new SessionState(false);

            sessionState.AddOrUpdateSubscription(SessionStateParser.MethodSubscriptionTopicPrefix, QualityOfService.AtLeastOnce);
            Task setTask = sessionProvider.SetAsync(identity, sessionState);

            Assert.True(setTask.IsCompleted);
            IEnumerable <(DeviceSubscription, bool)> list = new List <(DeviceSubscription, bool)> {
                (DeviceSubscription.Methods, true)
            };

            edgeHub.Verify(x => x.ProcessSubscriptions("d1", list), Times.Once);
        }