Пример #1
0
 public void Get_NonexistentCid()
 {
     using (var router = new ContentRouter())
     {
         var providers = router.Get(cid1);
         Assert.AreEqual(0, providers.Count());
     }
 }
Пример #2
0
        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());
            }
        }
Пример #3
0
        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());
            }
        }
Пример #4
0
        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);
            }
        }
Пример #5
0
        /// <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);
        }