Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
        }