public void Write_Writes_Out_The_Vna_File(string inFileName, string outFileName, int defaultNodeMapIndex, int defaultEdgeMapIndex, bool exportNodeData, bool exportEdgeData, bool isDirected) { var basicAdjListWriter = new VNABasicAdjListWriter(); IBasicAdjList net = null; using (var reader = new VnaAdjListReader()) { reader.File = Path.Combine(_dataDir, inFileName); reader.Read(); net = reader.Network as IBasicAdjList; } string outputFile = Path.Combine(_testDir, outFileName); basicAdjListWriter.NodeIdentifierAttributeIndex = defaultNodeMapIndex; basicAdjListWriter.EdgeIdentifierAttributeIndex = defaultEdgeMapIndex; basicAdjListWriter.ExportNodeAttributes = exportNodeData; basicAdjListWriter.ExportEdgeAttributes = exportEdgeData; basicAdjListWriter.FileName = outputFile; basicAdjListWriter.InputNetwork = net; basicAdjListWriter.Write(); bool exists = File.Exists(outputFile); Assert.True(exists); }
public void Reads_With_Items_That_Have_Known_Data_Field_Format_Issues(int testItemId) { // test items with known issues! var item = _data.TestItemsWithKnownErrors[testItemId]; var reader = new VnaAdjListReader(); reader.File = Path.Combine(_dataPath, item.FileName); reader.Read(); var result = reader.Network as IBasicAdjList; Assert.Null(result); Assert.True(reader.ErrorsHaveOccurred); }
public void Read_With_Items_That_Have_Known_Data_Field_Format_Issues_With_DisableDataConversions_Set_To_True(int testItemId) { // test items with known issues! _vnaReader = new VnaAdjListReader(); var item = _data.TestItemsWithKnownErrors[testItemId]; var reader = new VnaAdjListReader(); reader.DisableDataConversions = true; reader.File = Path.Combine(_dataPath, item.FileName); reader.Read(); var result = reader.Network as IBasicAdjList; Assert.NotNull(result); Assert.False(reader.ErrorsHaveOccurred); Assert.Equal(item.NodeCount, result.NodeCount); Assert.Equal(item.EdgeCount, result.EdgeCount); }
public void Read_Input_File_And_Verify_Random_Id_Assigned(int testItemId) { _vnaReader = new VnaAdjListReader(); var item = _data.TestItems[testItemId]; var reader = new VnaAdjListReader(); reader.File = Path.Combine(_dataPath, item.FileName); reader.Read(); var result = reader.Network; Assert.NotEqual(Guid.Empty, result.Id); }
public void Read_Input_File_And_Verify_NodeCount(int testItemId) { _vnaReader = new VnaAdjListReader(); var item = _data.TestItems[testItemId]; var reader = new VnaAdjListReader(); reader.File = Path.Combine(_dataPath, item.FileName); reader.Read(); var result = reader.Network; Assert.NotNull(result); Assert.Equal(item.NodeCount, result.NodeCount); }
public void Read_Input_File_And_Verify_NodeAttribs_Has_Expected_Count(int testItemId) { _vnaReader = new VnaAdjListReader(); var item = _data.TestItems[testItemId]; var reader = new VnaAdjListReader(); reader.File = Path.Combine(_dataPath, item.FileName); reader.Read(); var result = reader.Network as IBasicAdjList; Assert.NotNull(result); int expectedCount = item.NodeDataHeaderCountExpected + item.NodePropertyHeaderCountExpected; Assert.Equal(expectedCount, result.NodeDataAttributeCount); }
public void Read_Input_File_And_Verify_NodeAttribs_From_NodeProperties_Section(int testItemId) { _vnaReader = new VnaAdjListReader(); var item = _data.TestItems[testItemId]; var reader = new VnaAdjListReader(); reader.File = Path.Combine(_dataPath, item.FileName); reader.Read(); var result = reader.Network as IBasicAdjList; Assert.NotNull(result); bool containsName = false; bool matchesType = false; Type tmpType = null; for (int i = 0; i < item.NodePropertyHeaderCountExpected; i++) { for (int j = 0; j < result.NodeDataAttributeCount; j++) { if (item.NodePropertyHeadersExpected[i] == result.NodeDataAttributeNames[j]) { // find the expected header name in the NodeData and match its expcted type containsName = true; matchesType = VnaFileTestItem.IsMatch(item.NodePropertyTypesExpected[i], result.NodeDataAttributeTypes[j]); tmpType = result.NodeDataAttributeTypes[j]; break; } } Assert.True(containsName); Assert.True(matchesType); containsName = false; matchesType = false; } }