Example #1
0
        public void Router_CanCreate()
        {
            var basicHasher = new BasicHasher();
            var router = new Router(basicHasher);

            Assert.IsNotNull(router);
        }
Example #2
0
        public void E2E_CreateRouterAndRegisterNodes()
        {
            // Create router
            var basicHasher = new BasicHasher();
            var router = new Router(basicHasher);

            // Create a few nodes
            var nodes = new List<Node>();
            var nodesToCreate = 4;
            var startPort = 8000;
            for (int nodeId = 0; nodeId < nodesToCreate; nodeId++)
            {
                nodes.Add(new Node(nodeId, this.CreateEndpoint(LocalHost, startPort + nodeId)));
            }

            foreach (var node in nodes)
            {
                // Register endpoints with netsh to avoid permission errors
                Netsh.RegisterEndpoint(node.Endpoint);

                // Create node service
                var nodeService = NodeServiceFactory.CreateNodeService(node.NodeId, node.Endpoint);

                // Register with router
                router.RegisterNode(node.NodeId, node.Endpoint);
            }
        }
Example #3
0
        public void Router_CannotRegisterNodeWithSameId()
        {
            var basicHasher = new BasicHasher();
            var router = new Router(basicHasher);

            router.RegisterNode(0, new Uri(FakeEndpoint + "1"));
            router.RegisterNode(0, new Uri(FakeEndpoint + "2"));
        }
Example #4
0
        public void Router_CannotRegisterNodeWithSameEndpoint()
        {
            var basicHasher = new BasicHasher();
            var router = new Router(basicHasher);

            router.RegisterNode(0, FakeEndpointUri);
            router.RegisterNode(1, FakeEndpointUri);
        }
Example #5
0
        public void Router_CanRegisterNode()
        {
            var basicHasher = new BasicHasher();
            var router = new Router(basicHasher);

            var numberOfNodes = router.Nodes.Count;
            router.RegisterNode(0, FakeEndpointUri);

            Assert.AreEqual(numberOfNodes, 0);
            Assert.AreEqual(router.Nodes.Count, 1);
        }
Example #6
0
        public void Router_CanRegisterMultipleNodes()
        {
            var basicHasher = new BasicHasher();
            var router = new Router(basicHasher);

            var numberOfNodes = router.Nodes.Count;
            var nodesToRegister = 10;

            for (int nodeIdx = 0; nodeIdx < nodesToRegister; nodeIdx++)
            {
                router.RegisterNode(nodeIdx, new Uri(FakeEndpoint + nodeIdx));
            }

            Assert.AreEqual(numberOfNodes, 0);
            Assert.AreEqual(router.Nodes.Count, nodesToRegister);
        }