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 TestNewBeginAndEndMarkerCode() { DCMapping mapping = new DCMapping(); // Rename a marker and append a space to marker. mapping.BeginMarker = @"This* is A Test**"; mapping.EndMarker = @"\\NoChange*"; Assert.AreEqual(@"\This+ is A Test+*", mapping.NewBeginMarker); Assert.AreEqual(mapping.EndMarker, mapping.NewEndMarker); }
public void TestInlineTokenModify() { DCMapping mapping = new DCMapping(); // common settings for both test cases mapping.MarkerEncoding = ""; mapping.DataEncoding = ""; mapping.IsInline = true; mapping.EndMarker = ""; // Rename a marker and append a space to marker. mapping.BeginMarker = @"|fn"; MarkerSpec imsRenamed = MarkerSpec.CreateMarkerSpec(mapping); MarkerToken itRenamed = (MarkerToken)((MarkerSpec)imsRenamed).MakeToken(0, 0); itRenamed.Map = ""; Assert.AreEqual(@"\|fn", itRenamed.Output(true)); // TE-1856 space is no longer inserted after inline markers // Don't rename a marker. mapping.BeginMarker = @"\fn"; MarkerSpec imsNoChange = MarkerSpec.CreateMarkerSpec(mapping); MarkerToken itNoChange = (MarkerToken)((MarkerSpec)imsNoChange).MakeToken(0, 0); itNoChange.Map = ""; Assert.AreEqual(@"\fn", itNoChange.Output(true)); }
public void TestFieldTokenModify() { DCMapping mapping = new DCMapping(); // common settings for both test cases mapping.MarkerEncoding = ""; mapping.DataEncoding = ""; mapping.IsInline = false; mapping.EndMarker = ""; // Rename a marker. mapping.BeginMarker = @"|v"; MarkerSpec fmsRenamed = MarkerSpec.CreateMarkerSpec(mapping); MarkerToken ftRenamed = (MarkerToken)((MarkerSpec)fmsRenamed).MakeToken(0, 0); ftRenamed.Map = ""; Assert.AreEqual(@"\|v ", ftRenamed.Output(true)); // Don't rename a marker. mapping.BeginMarker = @"\v"; MarkerSpec fmsNoChange = MarkerSpec.CreateMarkerSpec(mapping); MarkerToken ftNoChange = (MarkerToken)((MarkerSpec)fmsNoChange).MakeToken(0, 0); ftNoChange.Map = ""; Assert.AreEqual(@"\v ", ftNoChange.Output(true)); }
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); } }