- Don't handle Invocation when no InvocationHandler is present
This commit is contained in:
parent
f87e0234e2
commit
3d29b7854b
|
|
@ -212,6 +212,7 @@ namespace Microsoft.AspNetCore.SignalR.Client
|
||||||
if (!_handlers.TryGetValue(invocationDescriptor.Method, out InvocationHandler handler))
|
if (!_handlers.TryGetValue(invocationDescriptor.Method, out InvocationHandler handler))
|
||||||
{
|
{
|
||||||
_logger.LogWarning("Failed to find handler for '{0}' method", invocationDescriptor.Method);
|
_logger.LogWarning("Failed to find handler for '{0}' method", invocationDescriptor.Method);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Return values
|
// TODO: Return values
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNetCore.Client.Tests;
|
using Microsoft.AspNetCore.Client.Tests;
|
||||||
using Microsoft.AspNetCore.SignalR.Tests.Common;
|
using Microsoft.AspNetCore.SignalR.Tests.Common;
|
||||||
|
using Microsoft.AspNetCore.Sockets;
|
||||||
using Microsoft.AspNetCore.Sockets.Client;
|
using Microsoft.AspNetCore.Sockets.Client;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Moq;
|
using Moq;
|
||||||
|
|
@ -246,5 +247,29 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests
|
||||||
var thrown = await Assert.ThrowsAsync(exception.GetType(), async () => await invokeTask);
|
var thrown = await Assert.ThrowsAsync(exception.GetType(), async () => await invokeTask);
|
||||||
Assert.Same(exception, thrown);
|
Assert.Same(exception, thrown);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task DoesNotThrowWhenClientMethodCalledButNoInvocationHandlerHasBeenSetUp()
|
||||||
|
{
|
||||||
|
var mockConnection = new Mock<IConnection>();
|
||||||
|
|
||||||
|
var invocationDescriptor = new InvocationDescriptor
|
||||||
|
{
|
||||||
|
Method = "NonExistingMethod123",
|
||||||
|
Arguments = new object[] { true, "arg2", 123 },
|
||||||
|
Id = Guid.NewGuid().ToString()
|
||||||
|
};
|
||||||
|
|
||||||
|
var mockInvocationAdapter = new Mock<IInvocationAdapter>();
|
||||||
|
mockInvocationAdapter
|
||||||
|
.Setup(a => a.ReadMessageAsync(It.IsAny<Stream>(), It.IsAny<IInvocationBinder>(), It.IsAny<CancellationToken>()))
|
||||||
|
.Returns(Task.FromResult((InvocationMessage)invocationDescriptor));
|
||||||
|
|
||||||
|
var hubConnection = new HubConnection(mockConnection.Object, mockInvocationAdapter.Object, null);
|
||||||
|
await hubConnection.StartAsync(Mock.Of<ITransport>());
|
||||||
|
|
||||||
|
mockConnection.Raise(c => c.Received += null, new object[] { new byte[] { }, MessageType.Text });
|
||||||
|
mockInvocationAdapter.Verify(a => a.ReadMessageAsync(It.IsAny<Stream>(), It.IsAny<IInvocationBinder>(), It.IsAny<CancellationToken>()), Times.Once());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue