public void UnsubscribeStopsEachTheOrderListener()
        {
            // Arrange
            var mockOrderListener = MockRepository.GenerateMock<IStreamingListener<OrderDTO>>();
            var mockOrderListener2 = MockRepository.GenerateMock<IStreamingListener<OrderDTO>>();

            _mockLsStreamingClientAccountConnection.Expect(x => x.BuildOrderListener(Arg<string>.Is.Anything))
                .Return(mockOrderListener)
                .Repeat.Once();

            _mockLsStreamingClientAccountConnection.Expect(x => x.BuildOrderListener(Arg<string>.Is.Anything))
               .Return(mockOrderListener2)
               .Repeat.Once();

            mockOrderListener.Expect(x => x.Stop());
            mockOrderListener2.Expect(x => x.Stop());

            // Act
            var orderStream = new OrderStream(_mockLsStreamingClientAccountConnection);
            
            //Two subscribtions
            orderStream.SubscribeToOrders();
            orderStream.SubscribeToOrders();

            orderStream.Unsubscribe();

            // Assert
            _mockLsStreamingClientAccountConnection.VerifyAllExpectations();
            mockOrderListener.VerifyAllExpectations();
            mockOrderListener2.VerifyAllExpectations();
        }
        public OrderStream Create(ILsStreamingClientAccountConnection lsCityindexStreamingClientConnection)
        {
            try
            {
                Log.Info("Creating order stream listener.");

                var orderStream = new OrderStream(lsCityindexStreamingClientConnection);

                return orderStream;
            }
            catch (Exception ex)
            {
                Log.Error(ex);
                throw;
            }
        }
        public void ValidSubscribtionsAreAddedToAToOrderStreamListenerList()
        {
            // Arrange
            var mockOrderListener = MockRepository.GenerateMock<IStreamingListener<OrderDTO>>();

            _mockLsStreamingClientAccountConnection.Expect(x => x.BuildOrderListener(Arg<string>.Is.Anything))
                .Return(mockOrderListener)
                .Repeat.Twice();

            // Act
            var orderStream = new OrderStream(_mockLsStreamingClientAccountConnection);
            orderStream.SubscribeToOrders();
            orderStream.SubscribeToOrders();

            // Assert
            Assert.AreEqual(2, orderStream.Listeners.Count);
            _mockLsStreamingClientAccountConnection.VerifyAllExpectations();
            mockOrderListener.VerifyAllExpectations();
        }