private void CallViaHub() { if (string.IsNullOrEmpty(GroupName) || string.IsNullOrEmpty(MethodToCall) || string.IsNullOrEmpty(HubName)) { throw new ArgumentException( "GroupName,MethodToCall & HubName are mandatory when CallViaPersistentConnection is set to false"); } var hubconnection = new HubConnectionProxy(Uri); PublishToSignalR = new PublishToHub(hubconnection, GroupName, MethodToCall, HubName); }
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); }
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); }