public void Should_Throw_SignalR_Exception_If_Connection_Is_Not_Made() { var publisher = new FakePublishToHub(_connectionProxyMock, "groupName", "methodToCallOnServer", ""); _connectionProxyMock.StartConnection(_httpClientMock).Returns(info => Task.FromResult(true)); var proxy = Substitute.For<IHubProxy>(); _connectionProxyMock.CreateProxy("").Returns(proxy); _connectionProxyMock.State.Returns(ConnectionState.Connecting); var message = new Message(); //Act try { publisher.Execute_SendToSignalR(message); Assert.Fail("Above line-Should have thrown exception"); } catch (SignalRConnectorTargetException) { } }
public void SendToSignalR_Send_Message_To_Specific_MethodCall_Only() { //Arrange var publisher = new FakePublishToHub(_connectionProxyMock, "groupName", "methodToCallOnServer", ""); _connectionProxyMock.StartConnection(_httpClientMock).Returns(info => Task.FromResult(true)); var proxy = Substitute.For<IHubProxy>(); _connectionProxyMock.CreateProxy("").Returns(proxy); _connectionProxyMock.State.Returns(ConnectionState.Connected); publisher.HubProxy = proxy; publisher.Connect(_httpClientMock); var message = new Message(); //Act publisher.Execute_SendToSignalR(message); proxy.Received(1) .Invoke(Arg.Is("methodToCallOnServer"), Arg.Is<object[]>(x => x[0] == message && x[1].ToString() == "groupName")); }
public void SendToSignalR_Should_Set_SentToSignalR_Flag_To_True_On_Success() { //Arrange var publisher = new FakePublishToHub(_connectionProxyMock, "", "", ""); _connectionProxyMock.StartConnection(_httpClientMock).Returns(info => Task.FromResult(true)); var proxy = Substitute.For<IHubProxy>(); _connectionProxyMock.CreateProxy("").Returns(proxy); _connectionProxyMock.State.Returns(ConnectionState.Connected); publisher.Connect(_httpClientMock); //Act publisher.Execute_SendToSignalR(new Message()); Assert.IsTrue(publisher.SentToSignalR); }