本文整理汇总了C#中Peer.ToPeerDescriptor方法的典型用法代码示例。如果您正苦于以下问题:C# Peer.ToPeerDescriptor方法的具体用法?C# Peer.ToPeerDescriptor怎么用?C# Peer.ToPeerDescriptor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Peer
的用法示例。
在下文中一共展示了Peer.ToPeerDescriptor方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Setup
public void Setup()
{
_configurationMock = new Mock<IDirectoryConfiguration>();
_bus = new TestBus();
var peer = new Peer(new PeerId("Abc.Testing.0"), "tcp://abctest:12300");
var peerDescriptor = peer.ToPeerDescriptor(true);
_entry = new DeadPeerDetectorEntry(peerDescriptor, _configurationMock.Object, _bus, new CurrentThreadTaskScheduler());
}
示例2: should_re_register_peer
public void should_re_register_peer()
{
var peers = new List<PeerDescriptor>();
_bus.AddHandler<RegisterPeerCommand>(x => new RegisterPeerResponse(peers.ToArray()));
var peer1 = new Peer(new PeerId("Abc.X.1"), "tcp://x:1");
peers.Add(peer1.ToPeerDescriptor(true, typeof(FakeCommand)));
_directory.Register(_bus, _self, new Subscription[0]);
_directory.GetPeersHandlingMessage(new FakeCommand(0)).ExpectedSingle().Id.ShouldEqual(peer1.Id);
peers.Clear();
var peer2 = new Peer(new PeerId("Abc.X.2"), "tcp://x:2");
peers.Add(peer2.ToPeerDescriptor(true, typeof(FakeCommand)));
_directory.Register(_bus, _self, new Subscription[0]);
_directory.GetPeersHandlingMessage(new FakeCommand(0)).ExpectedSingle().Id.ShouldEqual(peer2.Id);
}
示例3: should_have_unique_peer_instance_for_all_messages
public void should_have_unique_peer_instance_for_all_messages()
{
_directory.Handle(new PeerStarted(_otherPeer.ToPeerDescriptor(true, typeof(FakeEvent))));
_directory.Handle(new PeerStopped(_otherPeer));
var otherPeerWithNewEndPoint1 = new Peer(_otherPeer.Id, "tcp://wtf:1");
_directory.Handle(new PeerStarted(otherPeerWithNewEndPoint1.ToPeerDescriptor(true, typeof(FakeEvent), typeof(OtherFakeEvent1))));
_directory.Handle(new PeerStopped(otherPeerWithNewEndPoint1));
var otherPeerWithNewEndPoint2 = new Peer(_otherPeer.Id, "tcp://wtf:2");
_directory.Handle(new PeerStarted(otherPeerWithNewEndPoint2.ToPeerDescriptor(true, typeof(FakeEvent), typeof(OtherFakeEvent1), typeof(OtherFakeEvent2))));
var peer1 = _directory.GetPeersHandlingMessage(new FakeEvent(0)).ExpectedSingle();
var peer2 = _directory.GetPeersHandlingMessage(new OtherFakeEvent1()).ExpectedSingle();
var peer3 = _directory.GetPeersHandlingMessage(new OtherFakeEvent2()).ExpectedSingle();
peer1.EndPoint.ShouldEqual(peer2.EndPoint);
peer1.EndPoint.ShouldEqual(peer3.EndPoint);
}
示例4: should_not_impact_other_peers_when_decommissioning_a_peer
public void should_not_impact_other_peers_when_decommissioning_a_peer()
{
var anotherPeer = new Peer(new PeerId("Abc.Testing.2"), "tcp://abctest:987");
_directory.Handle(new PeerStarted(_otherPeer.ToPeerDescriptor(true, typeof(FakeEvent))));
_directory.Handle(new PeerStarted(anotherPeer.ToPeerDescriptor(true, typeof(FakeEvent))));
_directory.Handle(new PeerDecommissioned(anotherPeer.Id));
var peers = _directory.GetPeersHandlingMessage(new FakeEvent(0));
peers.Count.ShouldEqual(1);
}
示例5: should_support_multiple_peers_for_same_message
public void should_support_multiple_peers_for_same_message()
{
var otherPeer2 = new Peer(new PeerId("Abc.Testing.2"), "tcp://abctest:987");
_directory.Handle(new PeerStarted(_otherPeer.ToPeerDescriptor(true, typeof(FakeEvent))));
_directory.Handle(new PeerStarted(otherPeer2.ToPeerDescriptor(true, typeof(FakeEvent))));
var peers = _directory.GetPeersHandlingMessage(new FakeEvent(0));
peers.Count.ShouldEqual(2);
}
示例6: should_update_peers
public void should_update_peers()
{
_directory.Handle(new PeerStarted(_otherPeer.ToPeerDescriptor(true, typeof(FakeEvent), typeof(OtherFakeEvent1))));
_directory.Handle(new PeerStopped(_otherPeer));
const string newEndPoint = "tcp://new-end-point:111";
var newPeer = new Peer(_otherPeer.Id, newEndPoint);
_directory.Handle(new PeerStarted(newPeer.ToPeerDescriptor(true, typeof(FakeCommand), typeof(OtherFakeEvent1))));
_directory.GetPeersHandlingMessage(new FakeEvent(0)).ShouldBeEmpty();
var peer = _directory.GetPeersHandlingMessage(new FakeCommand(0)).Single();
peer.Id.ShouldEqual(_otherPeer.Id);
peer.EndPoint.ShouldEqual(newEndPoint);
var peer2 = _directory.GetPeersHandlingMessage(new OtherFakeEvent1()).Single();
peer2.Id.ShouldEqual(_otherPeer.Id);
peer2.EndPoint.ShouldEqual(newEndPoint);
}