コード例 #1
0
        public void IfLoggedInThenLogoutCallsDisconnectsTheStreamingManager()
        {
            // Arrange
            CiApi.Instance.SetUpApiForMocking(_mockApiConnection, _mockStreamingManager);
            SetUpApiInstanceToBeLoggedOut();

            // Login
            var apiLogOnResponseDTO = new ApiLogOnResponseDTO()
            {
                Session = "session"
            };

            _mockApiConnection.Expect(x => x.Login(USERNAME, PASSWORD, TRADING_URL)).Return(apiLogOnResponseDTO);

            _mockStreamingManager.Expect(x => x.Disconnect());

            // Act
            CiApi.Instance.Login(USERNAME, PASSWORD, TRADING_URL);
            CiApi.Instance.Logout();

            // Assert
            _mockStreamingManager.VerifyAllExpectations();
        }
コード例 #2
0
        public void PriceStreamPropertyConnectsToTheCityIndexStreamingAdapterTheFirstTimeItsCalled()
        {
            //Arrange
            _mockStreamingManager.Expect(x => x.LightStreamerConnectionManager)
            .Return(_mockLightStreamerConnectionManager)
            .Repeat.Any();

            _mockLightStreamerConnectionManager.Expect(x => x.LsCityindexStreamingConnection)
            .Return(_mockLsCityindexStreamingConnection)
            .Repeat.Any();

            _mockLightStreamerConnectionManager.Expect(x => x.CityindexStreamingAdaterIsConnected)
            .Return(false);

            _mockStreamingManager.Expect(x => x.StreamingUrl).Return(STREAMING_URL);

            string streamingUrlUsed = "";

            _mockLightStreamerConnectionManager.Expect(x => x.ConnectToCityindexStreamingAdapter(Arg <string> .Is.Anything,
                                                                                                 Arg <LsCityindexStreamingConnectionFactory> .Is.Anything))
            .Repeat.Once()
            .WhenCalled(x => streamingUrlUsed = (string)x.Arguments[0]);

            // Act
            var priceStream = _streams.PriceStream;

            // Assert
            Assert.AreEqual(STREAMING_URL, streamingUrlUsed);
            _mockStreamingManager.VerifyAllExpectations();
            _mockLightStreamerConnectionManager.VerifyAllExpectations();
        }