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)); }
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")); }
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)); }