ConnectToCityindexStreamingAdapter() 공개 메소드

public ConnectToCityindexStreamingAdapter ( string streamingUrl, LsCityindexStreamingConnectionFactory lsCityindexStreamingConnectionFactory ) : void
streamingUrl string
lsCityindexStreamingConnectionFactory TradingApi.Client.Framework.Streaming.LightStreamer.Connection.Factory.LsCityindexStreamingConnectionFactory
리턴 void
        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();
        }
        public void ThrowsInvalidOperationExceptionIfTryToConnectToCityindexStreamingAdapterTwice()
        {
            //Arrange
            _mockLsCityindexStreamingConnectionFactory.Expect(
                x => x.Create(Arg<Uri>.Is.Anything, Arg<string>.Is.Anything, Arg<string>.Is.Anything))
                .Return(_mockLsCityindexStreamingConnection)
                .Repeat.Any();

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

            // Act
            var lightStreamerConnectionManager = new LightStreamerConnectionManager(_mockApiConnection);
            //first call
            lightStreamerConnectionManager.ConnectToCityindexStreamingAdapter(STREAMING_URL, _mockLsCityindexStreamingConnectionFactory);
            //second call
            lightStreamerConnectionManager.ConnectToCityindexStreamingAdapter(STREAMING_URL, _mockLsCityindexStreamingConnectionFactory);

            // Assert
            _mockLsCityindexStreamingConnectionFactory.VerifyAllExpectations();
            _mockLsCityindexStreamingConnection.VerifyAllExpectations();
        }
        public void LightStreamerConnectionManagerDisconnectCallsDisconnectOnTheConnectionsIfNotNull()
        {
            // Arrange
            // Create a valid lightstreamer connections
            _mockLsCityindexStreamingConnectionFactory.Expect(
                x => x.Create(Arg<Uri>.Is.Anything, Arg<string>.Is.Anything, Arg<string>.Is.Anything))
                .Return(_mockLsCityindexStreamingConnection);

            _mockLsStreamingClientAccountConnectionFactory.Expect(
                x => x.Create(Arg<Uri>.Is.Anything, Arg<string>.Is.Anything, Arg<string>.Is.Anything))
                .Return(_mockLsStreamingClientAccountConnection);

            _mockLsCityindexStreamingConnection.Expect(x => x.Disconnect()).Repeat.Once();
            _mockLsStreamingClientAccountConnection.Expect(x => x.Disconnect()).Repeat.Once();

            // Act
            var lightStreamerConnectionManager = new LightStreamerConnectionManager(_mockApiConnection);
            lightStreamerConnectionManager.ConnectToStreamingClientAccountAdapter(STREAMING_URL, _mockLsStreamingClientAccountConnectionFactory);
            lightStreamerConnectionManager.ConnectToCityindexStreamingAdapter(STREAMING_URL, _mockLsCityindexStreamingConnectionFactory);

            // Act - then disconnect
            lightStreamerConnectionManager.Disconnect();
            // this time we do not expect the lightstreamerClientConnection Disconnect to be called
            lightStreamerConnectionManager.Disconnect();

            // Assert
            Assert.IsFalse(lightStreamerConnectionManager.StreamingClientAccountAdapterIsConnected);
            Assert.IsFalse(lightStreamerConnectionManager.CityindexStreamingAdaterIsConnected);
            _mockLsCityindexStreamingConnectionFactory.VerifyAllExpectations();
            _mockLsStreamingClientAccountConnectionFactory.VerifyAllExpectations();
            _mockLsCityindexStreamingConnection.VerifyAllExpectations();
            _mockLsStreamingClientAccountConnection.VerifyAllExpectations();
        }