public void CreateChatRoom() { string testChannelName = "testChannel"; string testUserName = "******"; string contextId = "1"; dynamic channel = new ExpandoObject(); IRequest request = base.BuildTestRequest().Object; var mockClients = new Mock <IHubCallerConnectionContext <dynamic> >(); mockClients.Setup(m => m.All).Returns((ExpandoObject)channel); mockGroupManager.Setup(m => m.Add(contextId, testChannelName)).Callback(() => this.isSent = true); var mockHubCallerContext = new Mock <HubCallerContext>(request, contextId); channel.sendChannelCreationMessage = new Action <string, string>((channelName, userName) => { this.isSent = true; Assert.AreEqual(testChannelName, channelName, "the channel was not supplied correctly"); Assert.AreEqual(testUserName, userName, "the user name was not supplied correctly"); }); ChatHub hub = new ChatHub() { Context = mockHubCallerContext.Object, Clients = mockClients.Object, Groups = mockGroupManager.Object }; hub.CreateChatChannel(testChannelName, testUserName); }