コード例 #1
0
        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);
        }
コード例 #2
0
        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
ファイル: SignalRTarget.cs プロジェクト: Hdesai/NLogToSignalR
        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();
            }
        }