public void AllShouldContainClientAfterAdd()
        {
            AppConnectedClientRepository <TestConnectedClient> repo = new AppConnectedClientRepository <TestConnectedClient>();

            TestConnectedClient expected = new TestConnectedClient {
                OtherProp = "foobar"
            };

            repo.Add(expected);

            IList <TestConnectedClient> actual = repo.All();

            Assert.IsTrue(actual.Any(c => c.Id == expected.Id));
        }
        public void Initialize()
        {
            IConnectedClientRepository <WcfConnectedClient> repo = new AppConnectedClientRepository <WcfConnectedClient>();
            WcfMessageHubService instance = new WcfMessageHubService(repo);

            svc = new ServiceHost(instance);
            svc.AddServiceEndpoint(typeof(IMessageHubService), new NetTcpBinding(), "net.tcp://localhost:8000/TestHubService");
            svc.Open();

            test = new TestServiceReceiver();

            svcChannel = new DuplexChannelFactory <IMessageHubService>(test, new NetTcpBinding(), new EndpointAddress("net.tcp://localhost:8000/TestHubService"));
            client     = svcChannel.CreateChannel();
        }
        public void SingleShouldReturnClientAfterAdd()
        {
            AppConnectedClientRepository <TestConnectedClient> repo = new AppConnectedClientRepository <TestConnectedClient>();

            TestConnectedClient expected = new TestConnectedClient {
                OtherProp = "foobar"
            };

            repo.Add(expected);

            TestConnectedClient actual = repo.Single(expected.Id);

            Assert.IsNotNull(actual);
            Assert.AreEqual(expected.Id, actual.Id);
            Assert.AreEqual(expected.OtherProp, actual.OtherProp);
        }
        public void ShouldNotHaveReceiverAfterRemoveReceiver()
        {
            var mockRepo    = new AppConnectedClientRepository <HubConnectedClient>();
            var hub         = new SignalRMessageHubService(mockRepo);
            var mockRequest = new Mock <IRequest>();

            hub.Context = new HubCallerContext(mockRequest.Object, "123");
            var mockGroups = new Mock <IGroupManager>();

            hub.Groups = mockGroups.Object;

            Guid recGuid = Guid.NewGuid();

            hub.AddReceiver(new ConnectedClientData(recGuid, null));

            hub.RemoveReceiver(recGuid);

            mockGroups.Verify(m => m.Remove(It.IsAny <string>(), "__receivers"), Times.Once);
        }
Example #5
0
        public void ClientShouldBeInRepoAfterAddReceiver()
        {
            var repo = new AppConnectedClientRepository <MsmqConnectedClient>();
            MsmqConnectedClient subject = new MsmqConnectedClient
            {
                Id = Guid.NewGuid()
            };

            using (MsmqMessageHubService testSvc = new MsmqMessageHubService(@".\private$\testSvc", repo))
            {
                testSvc.AddReceiver(subject);

                MsmqConnectedClient actual = repo.Single(subject.Id);
                Assert.IsNotNull(actual);
            }

            repo.Remove(subject.Id);
            subject.Dispose();
        }
        public void SingleShouldNotReturnClientAfterRemove()
        {
            AppConnectedClientRepository <TestConnectedClient> repo = new AppConnectedClientRepository <TestConnectedClient>();

            TestConnectedClient expected = new TestConnectedClient {
                OtherProp = "foobar"
            };

            repo.Add(expected);

            TestConnectedClient actual = repo.Single(expected.Id);

            Assert.IsNotNull(actual);

            repo.Remove(expected.Id);

            actual = repo.Single(expected.Id);

            Assert.IsNull(actual);
        }