Exemplo n.º 1
0
        public void should_get_peer_by_id()
        {
            var peerDescriptor = TestDataBuilder.CreatePersistentPeerDescriptor("tcp://badapple:123", typeof(string));

            _repositoryMock.Setup(repo => repo.Get(peerDescriptor.Peer.Id)).Returns(peerDescriptor);

            var fetchedPeerDescriptor = _peerDirectory.GetPeerDescriptor(peerDescriptor.PeerId);
            var fetchedPeer           = _peerDirectory.GetPeer(peerDescriptor.PeerId);

            fetchedPeerDescriptor.ShouldEqualDeeply(peerDescriptor);
            fetchedPeer.ShouldEqualDeeply(peerDescriptor.Peer);
        }
Exemplo n.º 2
0
        public void should_get_peer_with_matching_subscrition_binding_key()
        {
            var command = new FakeRoutableCommand(10, "u.name");

            var peerDescriptor = TestDataBuilder.CreatePersistentPeerDescriptor("tcp://goodapple:123", new Subscription(command.TypeId(), new BindingKey("10", "#")));

            _repositoryMock.Setup(x => x.GetPeers(It.IsAny <bool>())).Returns(new[] { peerDescriptor });

            var peer = _peerDirectory.GetPeersHandlingMessage(command).Single();

            peer.Id.ShouldEqual(peerDescriptor.Peer.Id);
        }
Exemplo n.º 3
0
        public void should_retrieve_the_peers_from_the_repository(bool disableDynamicSubscriptions)
        {
            _disableDynamicSubscriptionsForDirectoryOutgoingMessages = disableDynamicSubscriptions;
            _repositoryMock.Setup(repo => repo.GetPeers(It.Is <bool>(loadDynamicSubs => loadDynamicSubs != disableDynamicSubscriptions)))
            .Returns(new[]
            {
                TestDataBuilder.CreatePersistentPeerDescriptor("tcp://goodapple:123", typeof(FakeCommand)),
                TestDataBuilder.CreatePersistentPeerDescriptor("tcp://badapple:123", typeof(string))
            });

            var peersHandlingFakeCommand = _peerDirectory.GetPeersHandlingMessage(new FakeCommand()).ToList();

            peersHandlingFakeCommand.Count().ShouldEqual(1);
            peersHandlingFakeCommand.First().EndPoint.ShouldEqual("tcp://goodapple:123");
        }