public void Get_NonexistentCid() { using (var router = new ContentRouter()) { var providers = router.Get(cid1); Assert.AreEqual(0, providers.Count()); } }
public void Get_Expired() { using (var router = new ContentRouter()) { router.Add(cid1, self.Id, DateTime.MinValue); var providers = router.Get(cid1); Assert.AreEqual(0, providers.Count()); } }
public void Add() { using (var router = new ContentRouter()) { router.Add(cid1, self.Id); var providers = router.Get(cid1); Assert.AreEqual(1, providers.Count()); Assert.AreEqual(self.Id, providers.First()); } }
public void Add_MultipleProviders() { using (var router = new ContentRouter()) { router.Add(cid1, self.Id); router.Add(cid1, other.Id); var providers = router.Get(cid1).ToArray(); Assert.AreEqual(2, providers.Length); CollectionAssert.Contains(providers, self.Id); CollectionAssert.Contains(providers, other.Id); } }
/// <inheritdoc /> public Task StartAsync() { log.Debug("Starting"); RoutingTable = new RoutingTable(Swarm.LocalPeer); ContentRouter = new ContentRouter(); Swarm.AddProtocol(this); Swarm.PeerDiscovered += Swarm_PeerDiscovered; foreach (var peer in Swarm.KnownPeers) { RoutingTable.Add(peer); } return(Task.CompletedTask); }