public IntSetKadNode CreateNode(int nodeId)
        {
            RoutingTable <int> routingTable = Mother.CreateIntRoutingTable();
            var settings = new KademeliaSettings(TimeSpan.FromMilliseconds(100), 2, 5);

            return(new IntSetKadNode(new MockSetKadCore(routingTable, settings, CreateClientFromNodeId,
                                                        new NodeIdentifier <int>("", nodeId)), this));
        }
        public void returns_k_nearest_ordered()
        {
            RoutingTable <int> table = Mother.CreateIntRoutingTable();

            table.Add(new NodeIdentifier <int>("", 1));
            table.Add(new NodeIdentifier <int>("", 2));
            table.Add(new NodeIdentifier <int>("", 4));
            table.Add(new NodeIdentifier <int>("", 5));

            CollectionAssert.IsOrdered(table.NearTo(1).Select(n => n.NodeId),
                                       new LamdaComparer <int>((a, b) => a.CompareTo(b)));
        }
        public void returns_right_2_nearest()
        {
            RoutingTable <int> table = Mother.CreateIntRoutingTable();

            table.Add(new NodeIdentifier <int>("", 1));
            table.Add(new NodeIdentifier <int>("", 2));
            table.Add(new NodeIdentifier <int>("", 4));
            table.Add(new NodeIdentifier <int>("", 5));

            List <int> items = table.NearTo(2).Select(n => n.NodeId).ToList();

            Assert.AreEqual(items[0], 2);
            Assert.AreEqual(items[1], 1);
            Assert.AreEqual(items[2], 4);
            Assert.AreEqual(items[3], 5);
        }
 public IKadCore <int, string> GetParticipant()
 {
     return(new MockKadCore(Mother.CreateIntRoutingTable(), CreateClientFromNodeId));
 }