Esempio n. 1
0
        public void Connect_Should_Not_Set_IsConnected_To_True_When_Connection_State_Is_Not_Connected()
        {
            var hub = new PublishToHub(_connectionProxyMock, "", "", "");

            _connectionProxyMock.StartConnection(_httpClientMock).Returns(info => Task.FromResult(true));

            _connectionProxyMock.State.Returns(ConnectionState.Connecting);

            try
            {
                hub.Connect(_httpClientMock);
            }
            catch (SignalRConnectorTargetException)
            {
            }

            Assert.IsFalse(hub.IsConnected);
        }
Esempio n. 2
0
        public void Connect_Should_Set_IsConnected_To_True_When_Start_Task_Returns_Success()
        {
            var hub = new PublishToHub(_connectionProxyMock, "", "", "");

            _connectionProxyMock.CreateProxy("").Returns(x => new HubProxy(null, null));

            _connectionProxyMock.StartConnection(_httpClientMock).Returns(info => Task.FromResult(true));

            _connectionProxyMock.State.Returns(ConnectionState.Connected);

            hub.Connect(_httpClientMock);

            Assert.IsTrue(hub.IsConnected);
        }