public ConnectToStreamingClientAccountAdapter ( string streamingUrl, |
||
streamingUrl | string | |
lsStreamingClientAccountConnectionFactory | ||
return | void |
public void ConnectToStreamingClientAccountAdapterConnectsWithTheCorrectParametersAndReturnsIt() { //Arrange Uri streamingClientAccountAdapterUsed = null; _mockLsStreamingClientAccountConnectionFactory.Expect( x => x.Create(Arg<Uri>.Is.Anything, Arg<string>.Is.Anything, Arg<string>.Is.Anything)) .Return(_mockLsStreamingClientAccountConnection) .WhenCalled(x => streamingClientAccountAdapterUsed = (Uri)x.Arguments[0]); _mockLsStreamingClientAccountConnection.Expect(x => x.Connect()); // Act var lightStreamerConnectionManager = new LightStreamerConnectionManager(_mockApiConnection); lightStreamerConnectionManager.ConnectToStreamingClientAccountAdapter(STREAMING_URL, _mockLsStreamingClientAccountConnectionFactory); // Assert Assert.AreEqual(STREAMING_URL + "/" + STREAMINGCLIENTACCOUNT_ADAPTER, streamingClientAccountAdapterUsed.AbsoluteUri); Assert.AreEqual(_mockLsStreamingClientAccountConnection, lightStreamerConnectionManager.LsStreamingClientAccountConnection); Assert.IsTrue(lightStreamerConnectionManager.StreamingClientAccountAdapterIsConnected); _mockLsStreamingClientAccountConnectionFactory.VerifyAllExpectations(); _mockLsStreamingClientAccountConnection.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(); }
public void ThrowsInvalidOperationExceptionIfTryToConnectToStreamingClientAccountAdapterTwice() { //Arrange _mockLsStreamingClientAccountConnectionFactory.Expect( x => x.Create(Arg<Uri>.Is.Anything, Arg<string>.Is.Anything, Arg<string>.Is.Anything)) .Return(_mockLsStreamingClientAccountConnection) .Repeat.Any(); _mockLsStreamingClientAccountConnection.Expect(x => x.Connect()) .Repeat.Once(); // Act var lightStreamerConnectionManager = new LightStreamerConnectionManager(_mockApiConnection); //first call lightStreamerConnectionManager.ConnectToStreamingClientAccountAdapter(STREAMING_URL, _mockLsStreamingClientAccountConnectionFactory); //second call lightStreamerConnectionManager.ConnectToStreamingClientAccountAdapter(STREAMING_URL, _mockLsStreamingClientAccountConnectionFactory); // Assert _mockLsStreamingClientAccountConnectionFactory.VerifyAllExpectations(); _mockLsStreamingClientAccountConnection.VerifyAllExpectations(); }