aspnetcore/breaking-changes/7/ihubclients-ihubcallerclients.md
To add support for client results, xref:Microsoft.AspNetCore.SignalR.IHubClients and xref:Microsoft.AspNetCore.SignalR.IHubCallerClients now hide interface members IClientProxy Client(string connectionId); and IClientProxy Caller { get; } with ISingleClientProxy Client(string connectionId); and ISingleClientProxy Caller { get; }.
This is not a breaking change to production code unless you use reflection to call the affected Client or Caller methods. You may need to update unit testing SignalR Hubs.
ASP.NET Core 7.0
When using a testing library like Moq to unit test a SignalR Hub, you could write code similar to the following:
var hub = new MyHub();
var mockCaller = new Mock<IHubCallerClients>();
var mockClientProxy = new Mock<IClientProxy>();
mockCaller.Setup(x => x.Caller).Returns(mockClientProxy.Object);
hub.Clients = mockCaller.Object;
class MyHub : Hub { }
var hub = new MyHub();
var mockCaller = new Mock<IHubCallerClients>();
var mockClientProxy = new Mock<ISingleClientProxy>(); // <-- updated code
mockCaller.Setup(x => x.Caller).Returns(mockClientProxy.Object);
hub.Clients = mockCaller.Object;
class MyHub : Hub { }
This change affects source compatibility.
The change was made to add new functionality to SignalR. It is non-breaking in normal use cases, however, it may break test code, which is easily updated.
Update test code to use the ISingleClientProxy interface when using reflection or reflection-based code.