public void PopulateEdgeHeaderLists_Populates_Edge_Header_Dictionary_Keys_With_Source_Attrib_Col_Index(int it, string[] inputs, int[] expectedDataHeaderKeys, int[] expectedPropertyHeaderKeys)
        {
            var edgeDataHeaders = new Dictionary<int, string>();
            var edgePropertyHeaders = new Dictionary<int, string>();
            var helper = new KnownHeaderNamesWriterHelper();
            helper.PopulateEdgeHeaderLists(inputs, edgeDataHeaders, edgePropertyHeaders);

            Assert.Equal(expectedDataHeaderKeys.Length, edgeDataHeaders.Count);
            Assert.Equal(expectedPropertyHeaderKeys.Length, edgePropertyHeaders.Count);

            int ctr = 0;
            foreach (var edgeDataHeader in edgeDataHeaders.Keys)
            {
                Assert.Equal(expectedDataHeaderKeys[ctr++], edgeDataHeader);
            }
            ctr = 0;
            foreach (var edgePropertyHeader in edgePropertyHeaders.Keys)
            {
                Assert.Equal(expectedPropertyHeaderKeys[ctr++], edgePropertyHeader);
            }
        }
示例#2
0
        public void Write()
        {
            using(var helper = new KnownHeaderNamesWriterHelper())
            {
                helper.PopulateNodeHeaderLists(((IBasicAdjList)InputNetwork).NodeDataAttributeNames, NodeDataHeaders, NodePropertyHeaders);
                helper.PopulateEdgeHeaderLists(((IBasicAdjList)InputNetwork).EdgeDataAttributeNames, EdgeDataHeaders, EdgePropertyHeaders);
            }

            using (var sw = new StreamWriter(FileName))
            {
                WriteNodeDataSection(sw, (IBasicAdjList)InputNetwork, NodeDataHeaders);
                if(!DisablePropertyExport && NodePropertyHeaders.Count > 1) // if only 1, then no property headers other than Id
                    WriteNodePropertySection(sw, (IBasicAdjList)InputNetwork, NodePropertyHeaders);
                WriteEdgeDataSection(sw, (IBasicAdjList)InputNetwork, EdgeDataHeaders);
                if (!DisablePropertyExport && EdgePropertyHeaders.Count > 2)// if only 1, then no property headers other than From TO
                    WriteEdgePropertySection(sw, (IBasicAdjList)InputNetwork, EdgePropertyHeaders);
            }
        }
        public void PopulateNodeHeaderLists_Populates_Node_Header_Dictionary_Values_With_Header_Names_To_Use(int it, string[] inputs, string[] expectedDataHeaders, string[] expectedPropertyHeaders)
        {
            var nodeDataHeaders = new Dictionary<int, string>();
            var nodePropertyHeaders = new Dictionary<int, string>();
            var helper = new KnownHeaderNamesWriterHelper();
            helper.PopulateNodeHeaderLists(inputs, nodeDataHeaders, nodePropertyHeaders);

            Assert.Equal(expectedDataHeaders.Length, nodeDataHeaders.Count);
            Assert.Equal(expectedPropertyHeaders.Length, nodePropertyHeaders.Count);

            int ctr = 0;
            foreach (var nodeDataHeader in nodeDataHeaders.Values)
            {
                Assert.Equal(expectedDataHeaders[ctr++], nodeDataHeader);
            }
            ctr = 0;
            foreach (var nodePropertyHeader in nodePropertyHeaders.Values)
            {
                Assert.Equal(expectedPropertyHeaders[ctr++], nodePropertyHeader);
            }
        }
        public void PopulateNodeHeaderLists_Excludes_Specific_NodeAttribs(int it, string[] inputs, int[] expectedDataHeaderKeys, int[] expectedPropertyHeaderKeys)
        {
            var nodeDataHeaders = new Dictionary<int, string>();
            var nodePropertyHeaders = new Dictionary<int, string>();
            var helper = new KnownHeaderNamesWriterHelper();
            helper.PopulateNodeHeaderLists(inputs, nodeDataHeaders, nodePropertyHeaders);

            Assert.Equal(expectedDataHeaderKeys.Length, nodeDataHeaders.Count);
            Assert.Equal(expectedPropertyHeaderKeys.Length, nodePropertyHeaders.Count);

            int ctr = 0;
            foreach (var nodeDataHeader in nodeDataHeaders.Keys)
            {
                Assert.Equal(expectedDataHeaderKeys[ctr++], nodeDataHeader);
            }
            ctr = 0;
            foreach (var nodePropertyHeader in nodePropertyHeaders.Keys)
            {
                Assert.Equal(expectedPropertyHeaderKeys[ctr++], nodePropertyHeader);
            }
        }