public void TestDataConverter() { MarkerClass markerClass = new MarkerClass(); DataConverter dataConverter = new DataConverter(); DCMapping mapping; DCMapping[] mappings = new DCMapping[markerClass.markers.Length]; for (int i = 0; i < markerClass.markers.Length; i++) { MarkerClass.Marker marker = markerClass.markers[i]; mapping = new DCMapping(); mapping.BeginMarker = marker.m_marker; // the sample input file is ASCII text, so using ISO-8859-1 (Latin 1) // to convert to Unicode is a good choice. By specifiying an empty string // as the encoding name, the default Unicode conversion will be used, // which is ISO-8859-1 (Latin 1). mapping.MarkerEncoding = ""; mapping.DataEncoding = ""; mapping.IsInline = marker.m_isInline; mapping.EndMarker = marker.m_end; mappings[i] = mapping; } // location of sample sfm files string SFMFilePath = Info.TestFileDir; // IECProjectFileInfo fileInfo; // IECProjectFileInfo[] fileInfos = new IECProjectFileInfo[1]; DCFileInfo fileInfo; IDCFileInfo[] fileInfos = new IDCFileInfo[1]; // fileInfo = new ECProjectFileInfo(); fileInfo = new DCFileInfo(); fileInfo.InputFileName = SFMFilePath + @"input.sfm"; fileInfo.OutputFileName = SFMFilePath + @"output.sfm"; // fileInfo.HasBOM is initialized to 0 ... which works for this test. fileInfo.FileEncoding = DCFileEncoding.DC_FE_BYTES; fileInfos[0] = fileInfo; // convert the input files dataConverter.ConvertNew(mappings, fileInfos); }
public void TestInvalidFileName() { MarkerClass markerClass = new MarkerClass(); DataConverter dataConverter = new DataConverter(); DCMapping mapping; DCMapping[] mappings = new DCMapping[markerClass.markers.Length]; for (int i = 0; i < markerClass.markers.Length; i++) { MarkerClass.Marker marker = markerClass.markers[i]; mapping = new DCMapping(); mapping.BeginMarker = marker.m_marker; // use an undefined Encoding Repository name mapping.MarkerEncoding = ""; mapping.DataEncoding = ""; mapping.IsInline = marker.m_isInline; mapping.EndMarker = marker.m_end; mappings[i] = mapping; } // location of sample sfm files string SFMFilePath = Info.TestFileDir; DCFileInfo fileInfo; IDCFileInfo[] fileInfos = new IDCFileInfo[1]; fileInfo = new DCFileInfo(); fileInfo.InputFileName = SFMFilePath + @"inputxxxxx.sfm"; fileInfo.OutputFileName = SFMFilePath + @"output.sfm"; // fileInfo.HasBOM is initialized to 0 ... which works for this test. fileInfo.FileEncoding = DCFileEncoding.DC_FE_BYTES; fileInfos[0] = fileInfo; // convert the input files try { dataConverter.ConvertNew(mappings, fileInfos); Assert.Fail("ConvertNew didn't fail with non-existant input file."); } catch(System.IO.FileNotFoundException) { } catch(Exception e) { Assert.Fail("Unexpected Exception: " + e.Message); } }