コード例 #1
0
        public void Register_Subscription_SubscriptionIsNull()
        {
            // arrange
            var connection    = new SocketConnectionMock();
            var subscriptions = new SubscriptionManager(connection);
            var subscription  = new SubscriptionSessionMock();

            // act
            Action action = () => subscriptions.Register(null);

            // assert
            Assert.Throws <ArgumentNullException>(action);
        }
コード例 #2
0
        public void Register_Subscription()
        {
            // arrange
            var connection    = new SocketConnectionMock();
            var subscriptions = new SubscriptionManager(connection);
            var subscription  = new SubscriptionSessionMock();

            // act
            subscriptions.Register(subscription);

            // assert
            Assert.Collection(subscriptions,
                              t => Assert.Equal(subscription, t));
        }
コード例 #3
0
        public void Unregister_Subscription_SubscriptionIdIsNull()
        {
            // arrange
            var connection    = new SocketConnectionMock();
            var subscriptions = new SubscriptionManager(connection);
            var subscription  = new SubscriptionSessionMock();

            subscriptions.Register(subscription);
            Assert.Collection(subscriptions,
                              t => Assert.Equal(subscription, t));

            // act
            Action action = () => subscriptions.Unregister(null);

            // assert
            Assert.Throws <ArgumentNullException>(action);
        }
コード例 #4
0
        public void Unregister_Subscription_ManagerAlreadyDisposed()
        {
            // arrange
            var connection    = new SocketConnectionMock();
            var subscriptions = new SubscriptionManager(connection);
            var subscription  = new SubscriptionSessionMock {
                Id = "abc"
            };

            subscriptions.Register(subscription);
            subscriptions.Dispose();

            // act
            Action action = () => subscriptions.Unregister("abc");

            // assert
            Assert.Throws <ObjectDisposedException>(action);
        }
コード例 #5
0
        public void Dispose_Subscriptions()
        {
            // arrange
            var connection     = new SocketConnectionMock();
            var subscriptions  = new SubscriptionManager(connection);
            var subscription_a = new SubscriptionSessionMock();
            var subscription_b = new SubscriptionSessionMock();

            subscriptions.Register(subscription_a);
            subscriptions.Register(subscription_b);

            // act
            subscriptions.Dispose();

            // assert
            Assert.Empty(subscriptions);
            Assert.True(subscription_a.IsDisposed);
            Assert.True(subscription_a.IsDisposed);
        }