コード例 #1
0
ファイル: SessionStateTest.cs プロジェクト: darobs/iotedge-HA
        public void TestClearRegistrations_ShouldClearAllRegistrations()
        {
            var sessionState = new SessionState(false);

            sessionState.AddOrUpdateSubscription(MethodPostTopicPrefix, QualityOfService.AtLeastOnce);
            sessionState.AddOrUpdateSubscription("Sometopic", QualityOfService.AtLeastOnce);
            sessionState.ClearRegistrations();
            IReadOnlyDictionary <string, bool> registrations = sessionState.SubscriptionRegistrations;

            Assert.NotNull(registrations);
            Assert.Equal(registrations.Count, 0);
        }
コード例 #2
0
ファイル: SessionStateTest.cs プロジェクト: darobs/iotedge-HA
        public void TestRemoveSubscription_ShouldAddSubscritionDeregistration()
        {
            var sessionState = new SessionState(false);

            sessionState.AddOrUpdateSubscription(MethodPostTopicPrefix, QualityOfService.AtLeastOnce);
            sessionState.ClearRegistrations();

            sessionState.RemoveSubscription(MethodPostTopicPrefix);

            IReadOnlyDictionary <string, bool> registrations = sessionState.SubscriptionRegistrations;
            IReadOnlyList <ISubscription>      subs          = sessionState.Subscriptions;

            Assert.NotNull(registrations);
            Assert.Equal(registrations.Count, 1);
            Assert.True(registrations.ContainsKey(MethodPostTopicPrefix));
            Assert.False(registrations[MethodPostTopicPrefix]);
            Assert.NotNull(subs);
            Assert.Equal(subs.Count, 0);
        }