public void ConnectToCityindexStreamingAdapterConnectsWithTheCorrectParametersAndReturnsIt()
        {
            //Arrange
            Uri cityindexStreamingAdapterUsed = null;

            _mockLsCityindexStreamingConnectionFactory.Expect(
                x => x.Create(Arg <Uri> .Is.Anything, Arg <string> .Is.Anything, Arg <string> .Is.Anything))
            .Return(_mockLsCityindexStreamingConnection)
            .WhenCalled(x => cityindexStreamingAdapterUsed = (Uri)x.Arguments[0]);

            _mockLsCityindexStreamingConnection.Expect(x => x.Connect());

            // Act
            var lightStreamerConnectionManager = new LightStreamerConnectionManager(_mockApiConnection);

            lightStreamerConnectionManager.ConnectToCityindexStreamingAdapter(STREAMING_URL, _mockLsCityindexStreamingConnectionFactory);

            // Assert
            Assert.AreEqual(STREAMING_URL + "/" + CITYINDEXSTREAMING_ADAPTER, cityindexStreamingAdapterUsed.AbsoluteUri);

            Assert.AreEqual(_mockLsCityindexStreamingConnection, lightStreamerConnectionManager.LsCityindexStreamingConnection);
            Assert.IsTrue(lightStreamerConnectionManager.CityindexStreamingAdaterIsConnected);
            _mockLsCityindexStreamingConnectionFactory.VerifyAllExpectations();
            _mockLsCityindexStreamingConnection.VerifyAllExpectations();
        }
Exemplo n.º 2
0
        public void SubscribeToMarketPriceBuildsThePriceListenerCorrectlyStartsAndReturnsIt()
        {
            // Arrange
            const int marketId          = 1;
            var       mockPriceListener = MockRepository.GenerateMock <IStreamingListener <PriceDTO> >();

            _mockLsCityindexStreamingConnection.Expect(x => x.BuildPriceListener(PRICES_TOPIC + marketId))
            .Return(mockPriceListener);

            // Act
            new PriceStream(_mockLsCityindexStreamingConnection).SubscribeToMarketPrice(marketId);

            // Assert
            _mockLsCityindexStreamingConnection.VerifyAllExpectations();
            mockPriceListener.VerifyAllExpectations();
        }
        public void SubscribeToNewsBuildsTheNewsListenerCorrectlyStartsAndReturnsIt()
        {
            // Arrange
            var mockNewsListener = MockRepository.GenerateMock <IStreamingListener <NewsDTO> >();

            _mockLsCityindexStreamingConnection.Expect(x => x.BuildNewsHeadlinesListener("NEWS.HEADLINES." + REGION))
            .Return(mockNewsListener);

            mockNewsListener.Expect(x => x.Start());

            // Act
            new NewsStream(_mockLsCityindexStreamingConnection).SubscribeToNewsHeadlinesByRegion(REGION);

            // Assert
            _mockLsCityindexStreamingConnection.VerifyAllExpectations();
            mockNewsListener.VerifyAllExpectations();
        }