public void Connect_Should_Set_IsConnected_To_True_When_Start_Task_Returns_Success()
        {
            var persistentConnectionPublisher = new PersistentConnectionPublisher(_connectionProxyMock);

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

            persistentConnectionPublisher.Connect(_httpClientMock);

            Assert.IsTrue(persistentConnectionPublisher.IsConnected);
        }
        public void Connect_Should_Not_Set_IsConnected_To_True_When_Start_Task_Returns_Failure()
        {
            var persistentConnectionPublisher = new PersistentConnectionPublisher(_connectionProxyMock);

             _connectionProxyMock.StartConnection(_httpClientMock).Returns(info => {throw new Exception("test");});

             try
             {
                 persistentConnectionPublisher.Connect(_httpClientMock);
             }
             catch
             {

             }

             Assert.IsFalse(persistentConnectionPublisher.IsConnected);
        }
Пример #3
0
        private void SetPublisher()
        {
            if (PublishToSignalR != null)
            {
                return;
            }

            if (string.IsNullOrEmpty(Uri))
            {
                throw new ArgumentNullException(Uri);
            }

            //Try to set appropriate publisher if not set
            if (CallViaPersistentConnection)
            {
                PublishToSignalR = new PersistentConnectionPublisher(new ConnectionProxy((Uri)));
            }
            else
            {
                CallViaHub();
            }
        }
Пример #4
0
        private void SetPublisher()
        {
            if (PublishToSignalR != null)
            {
                return;
            }

            if (string.IsNullOrEmpty(Uri))
            {
                throw new ArgumentNullException(Uri);
            }

            //Try to set appropriate publisher if not set
            if (CallViaPersistentConnection)
            {
                PublishToSignalR = new PersistentConnectionPublisher(new ConnectionProxy((Uri)));
            }
            else
            {
                CallViaHub();
            }
        }