Ejemplo n.º 1
0
        public void TestSortingEdges()
        {
            var factory = new VirEntityFactory();

            Person node = new Person(factory);

            for (int i = 0; i < 5; i++)
            {
                IMatchEdge edge = (IMatchEdge)node.ConnectTo(new Person(factory), Core.Interfaces.EdgeDirection.Both);
                if (i % 2 == 0)
                {
                    edge.RemotePartitionId = factory.CreateId();
                }
            }

            // 3 out of 5 nodes are remote
            node.SortEdges();
            var list = node.Edges.Cast <IMatchEdge>().ToList();

            // first two are local
            Assert.False(list[0].IsRemote);
            Assert.False(list[1].IsRemote);

            // rest is remote
            Assert.True(list.Skip(2).All(e => e.IsRemote));
        }
Ejemplo n.º 2
0
        public void TestEdgesSerialization()
        {
            MemoryStream ms = new MemoryStream();
            var          f  = new VirEntityFactory();
            var          ns = new NodeSerializer(ms, f, new DummyContextFactory());

            var node = f.CreateNode();

            node.ConnectTo(f.CreateNode(), Core.Interfaces.EdgeDirection.Both);

            ns.Serialize(node);

            ms.Position = 0;
            Assert.Single(XDocument.Load(ms).Descendants("Edge"));
        }
Ejemplo n.º 3
0
        public void TestEdgeDeserialization()
        {
            MemoryStream ms = new MemoryStream();
            var          f  = new VirEntityFactory();
            var          ns = new NodeSerializer(ms, f, new DummyContextFactory());

            var node = new Person(f);

            node.ConnectTo(f.CreateNode(), Core.Interfaces.EdgeDirection.Both);

            ns.Serialize(node);

            ms.Position = 0;
            var nOut = ns.Deserialize();

            Assert.Single(nOut.Edges);
            Assert.IsAssignableFrom <IRemoteNode>(nOut.Edges.Single().GetOtherNode(nOut));
        }