public void reuseNodeValueByRef() { MasterNodeList<string> nodeList = new MasterNodeList<string>(); Dictionary<Node, List<Route>> prefixD = new Dictionary<Node, List<Route>>(); DataChunkRouteBlazerTest.threeThreeChunks(nodeList, prefixD); XmlDocument threeThreeDoc = new XMLGraphFormat<string>().ToXMLDocument(nodeList); XmlNode nodesElement = threeThreeDoc.DocumentElement.ChildNodes[0]; XmlNodeList nodeElements = nodesElement.ChildNodes; int firstAIndex = nodeList.getValueNodesByValue("A").ElementAt(0).SequenceNumber; int secondAIndex = nodeList.getValueNodesByValue("A").ElementAt(1).SequenceNumber; XmlNode secondAXmlElem = nodeElements[secondAIndex]; Assert.AreEqual(firstAIndex.ToString(), secondAXmlElem.Attributes[XMLGraphFormat<ushort>.VALUEREFATTR].Value); Assert.AreEqual("", secondAXmlElem.InnerText); MasterNodeList<string> destinationList = new MasterNodeList<string>(); Dictionary<Node, List<Route>> destinationDict = new Dictionary<Node, List<Route>>(); DataChunkRoute<string> firstRoute = nodeList.nthDataChunkRoute(0); var missingComponents = firstRoute.specsForMissingComponents(destinationList); Assert.AreEqual(4, missingComponents.Item1.Count); Assert.AreEqual(3, missingComponents.Item2.Count); destinationList.reloadNodesThenRoutesFromSpecs(missingComponents.Item1, missingComponents.Item2); DataChunkRoute<string> secondRoute = nodeList.nthDataChunkRoute(1); Assert.AreEqual(3,secondRoute.componentEdges.Count); Assert.AreEqual(1, secondRoute.componentEdges[0].edge.link.from.SequenceNumber); Assert.AreEqual(3, secondRoute.componentEdges[1].edge.link.from.SequenceNumber); Assert.AreEqual(6, secondRoute.componentEdges[2].edge.link.from.SequenceNumber); Assert.AreEqual(7, secondRoute.componentEdges[2].edge.link.to.SequenceNumber); foreach(EdgeRoute rt in secondRoute.componentEdges) { Assert.AreNotEqual(0, rt.edge.link.from.SequenceNumber); Assert.AreNotEqual(0, rt.edge.link.to.SequenceNumber); } var secondMissingComponents = secondRoute.specsForMissingComponents(destinationList); var secondMissingNodeSpecs = secondMissingComponents.Item1; Assert.AreEqual(3, secondMissingNodeSpecs.Count); var secondMissingEdgeSpecs = secondMissingComponents.Item2; XmlDocument secondMissingDoc = new XMLGraphFormat<string>().ToXMLDocument(destinationList, secondMissingNodeSpecs, secondMissingEdgeSpecs); Assert.AreEqual(2, secondMissingDoc.DocumentElement.ChildNodes.Count); nodesElement = secondMissingDoc.DocumentElement.ChildNodes[0]; nodeElements = nodesElement.ChildNodes; Assert.AreEqual(3, nodeElements.Count); Assert.AreEqual(NodeKind.GateNode.ToString(), nodeElements[0].Attributes[XMLGraphFormat<bool>.NODEKINDATTR].Value); Assert.AreEqual(NodeKind.ValueNode.ToString(), nodeElements[1].Attributes[XMLGraphFormat<bool>.NODEKINDATTR].Value); XmlNode AXmlElem = nodeElements[1]; Assert.AreEqual(6, Convert.ToInt32(AXmlElem.Attributes[XMLGraphFormat<bool>.SEQNUMATTR].Value)); Assert.AreEqual("", AXmlElem.InnerText); Assert.AreEqual(firstAIndex.ToString(), AXmlElem.Attributes[XMLGraphFormat<long>.VALUEREFATTR].Value); DataChunkRouteBlazer<string> blaz = new DataChunkRouteBlazer<string>(new List<string> { "G", "G", "G" }, nodeList); blaz.computeFullRoute(); DataChunkRoute<string> GGG = nodeList.nthDataChunkRoute(3); secondMissingComponents = GGG.specsForMissingComponents(destinationList); secondMissingNodeSpecs = secondMissingComponents.Item1; Assert.AreEqual(4, secondMissingNodeSpecs.Count); secondMissingDoc = new XMLGraphFormat<string>().ToXMLDocument(destinationList, secondMissingNodeSpecs, secondMissingEdgeSpecs); nodesElement = secondMissingDoc.DocumentElement.ChildNodes[0]; nodeElements = nodesElement.ChildNodes; XmlNode G2Elem = nodeElements[2]; Assert.AreEqual(NodeKind.ValueNode.ToString(), G2Elem.Attributes[XMLGraphFormat<bool>.NODEKINDATTR].Value); Assert.AreEqual("", G2Elem.InnerText); Assert.IsNotNull(G2Elem.Attributes[XMLGraphFormat<bool>.VALUEREFATTR]); }
public void findMissingRouteComponents() { setup13append(); MasterNodeList<string> destinationList = new MasterNodeList<string>(); Dictionary<Node,List<Route>> destinationDict = new Dictionary<Node, List<Route>>(); DataChunkRoute<string> ABC = list.nthDataChunkRoute(0); Tuple<IList<NodeSpec>, IList<EdgeRouteSpec>> missingComponents = ABC.specsForMissingComponents(destinationList); IEnumerable<NodeSpec> missingNodes = missingComponents.Item1; IEnumerable<EdgeRouteSpec> missingEdges = missingComponents.Item2; NodeSpec missingGate = missingNodes.First(node => node.kind == NodeKind.GateNode); Assert.AreEqual(1, missingNodes.Where(node => node.kind == NodeKind.GateNode).Count()); Assert.AreEqual(0, missingGate.SequenceNumber); NodeSpec newValueSpec = missingNodes.First(node => node.kind == NodeKind.ValueNode); Assert.AreEqual(6, newValueSpec.SequenceNumber); Assert.AreEqual(3, missingNodes.Where(node => node.kind == NodeKind.ValueNode).Count()); Assert.AreEqual(1, missingEdges.Where(edge => edge.FromNumber == missingGate.SequenceNumber).Count()); destinationList.reloadNodesThenRoutesFromSpecs(missingNodes, missingEdges); ValueNode<string> Anode = destinationList.getValueNodesByValue("A").First(); Assert.AreEqual("A", Anode.Value); Assert.AreEqual(6, Anode.SequenceNumber); DataChunkRoute<string> AAE = list.nthDataChunkRoute(2); missingComponents = AAE.specsForMissingComponents(destinationList); missingNodes = missingComponents.Item1; missingEdges = missingComponents.Item2; destinationList.reloadNodesThenRoutesFromSpecs(missingNodes, missingEdges); Assert.AreEqual(2, destinationList.getValueNodesByValue("A").Count()); int DnodeIndex = list.getValueNodesByValue("D").First().SequenceNumber; Assert.AreEqual(NodeKind.NullNode,destinationList.nodeByNumber(DnodeIndex).kind); }