public void should_not_get_peer_with_non_matching_subscrition_binding_key() { var command = new FakeRoutableCommand(10, "u.name"); var peerDescriptor = TestDataBuilder.CreatePersistentPeerDescriptor("tcp://goodapple:123", new Subscription(command.TypeId(), new BindingKey("12", "#"))); _repositoryMock.Setup(x => x.GetPeers(It.IsAny <bool>())).Returns(new[] { peerDescriptor }); _peerDirectory.GetPeersHandlingMessage(command).ShouldBeEmpty(); }
public void should_get_all_peers() { var peerDescriptor = TestDataBuilder.CreatePersistentPeerDescriptor("tcp://badapple:123", typeof(string)); _repositoryMock.Setup(repo => repo.GetPeers(It.IsAny <bool>())).Returns(new[] { peerDescriptor }); var fetchedPeerDescriptor = _peerDirectory.GetPeerDescriptors(); fetchedPeerDescriptor.Single().ShouldEqualDeeply(peerDescriptor); }
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.Peer.Id); fetchedPeerDescriptor.ShouldEqualDeeply(peerDescriptor); }
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"); }