Esempio n. 1
0
        public void CreateUser()
        {
            string  testUser    = "******";
            string  testMessage = String.Format("A user has signed up: {0}", testUser);
            dynamic userSignup  = new ExpandoObject();

            userSignup.sendUserCreatedMessage = new Action <string>((user) =>
            {
                this.isSent = true;
                Assert.AreEqual(testMessage, user, "the user was not supplied correctly");
            });

            IRequest request     = base.BuildTestRequest().Object;
            var      mockClients = new Mock <IHubCallerConnectionContext <dynamic> >();

            mockClients.Setup(m => m.All).Returns((ExpandoObject)userSignup);

            var mockHubCallerContext = new Mock <HubCallerContext>(request, "1");

            ChatHub hub = new ChatHub()
            {
                Context = mockHubCallerContext.Object,
                Clients = mockClients.Object,
                Groups  = mockGroupManager.Object
            };

            hub.CreateUser(testUser);
        }