Exemplo n.º 1
0
        public void Register_Subscription_SubscriptionIsNull()
        {
            // arrange
            var connection    = new SocketConnectionMock();
            var subscriptions = new SubscriptionManager(connection);
            var subscription  = new SubscriptionMock();

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

            // assert
            Assert.Throws <ArgumentNullException>(action);
        }
Exemplo n.º 2
0
        public void Register_Subscription()
        {
            // arrange
            var connection    = new SocketConnectionMock();
            var subscriptions = new SubscriptionManager(connection);
            var subscription  = new SubscriptionMock();

            // act
            subscriptions.Register(subscription);

            // assert
            Assert.Collection(subscriptions,
                              t => Assert.Equal(subscription, t));
        }
Exemplo n.º 3
0
        public void Unregister_Subscription_SubscriptionIdIsNull()
        {
            // arrange
            var connection    = new SocketConnectionMock();
            var subscriptions = new SubscriptionManager(connection);
            var subscription  = new SubscriptionMock();

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

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

            // assert
            Assert.Throws <ArgumentNullException>(action);
        }
Exemplo n.º 4
0
        public void Unregister_Subscription_ManagerAlreadyDisposed()
        {
            // arrange
            var connection    = new SocketConnectionMock();
            var subscriptions = new SubscriptionManager(connection);
            var subscription  = new SubscriptionMock {
                Id = "abc"
            };

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

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

            // assert
            Assert.Throws <ObjectDisposedException>(action);
        }
Exemplo n.º 5
0
        public void Dispose_Subscriptions()
        {
            // arrange
            var connection     = new SocketConnectionMock();
            var subscriptions  = new SubscriptionManager(connection);
            var subscription_a = new SubscriptionMock();
            var subscription_b = new SubscriptionMock();

            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);
        }