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 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 SetUp() { _mockStreamingManager = MockRepository.GenerateMock <IStreamingManager>(); _mockPriceStreamFactory = MockRepository.GenerateMock <IPriceStreamFactory>(); _mockNewsStreamFactory = MockRepository.GenerateMock <INewsStreamFactory>(); _mockOrderStreamFactory = MockRepository.GenerateMock <IOrderStreamFactory>(); _streams = new Streams(_mockStreamingManager, _mockPriceStreamFactory, _mockNewsStreamFactory, _mockOrderStreamFactory); _mockLsCityindexStreamingConnection = MockRepository.GenerateMock <ILsCityindexStreamingConnection>(); _mockLStreamingClientAccountConnection = MockRepository.GenerateMock <ILsStreamingClientAccountConnection>(); _mockApiConnection = MockRepository.GenerateMock <IApiConnection>(); _mockLightStreamerConnectionManager = MockRepository.GenerateMock <LightStreamerConnectionManager>(_mockApiConnection); }
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(); }
internal StreamingManager(LightStreamerConnectionManager lightStreamerConnectionManager) { _lightStreamerConnectionManager = lightStreamerConnectionManager; }
public void SetUp() { _mockApiConnection = MockRepository.GenerateMock <IApiConnection>(); _mockLightStreamerConnectionManager = MockRepository.GenerateMock <LightStreamerConnectionManager>(_mockApiConnection); _streamingManager = new StreamingManager(_mockLightStreamerConnectionManager); }