public void DataFileInvalid_InvalidBook() { using (TempSFFileMaker fileMaker = new TempSFFileMaker()) { string sFilename = fileMaker.CreateFileNoID( new string[] {@"\id Hmmm", @"\mt Genesis", @"\id GEN", @"\c 1", @"\v 1 Valid"}); try { new ScrImportFileInfo(sFilename, m_mappingList, ImportDomain.Main, null, 0, true); Assert.Fail("Failed to throw an exception."); } catch (ScriptureUtilsException e) { Assert.AreEqual(SUE_ErrorCode.InvalidBookID, e.ErrorCode); } catch { Assert.Fail("Wrong exception detected."); } } }
public void TestExcludeBeforeIDLine() { CheckDisposed(); using (TempSFFileMaker fileMaker = new TempSFFileMaker()) { string fileName = fileMaker.CreateFileNoID( new string[] { @"\_sh", @"\id EPH", @"\mt Ephesians", @"\c 1", @"\v 1 hello there"}); m_settings.AddFile(fileName, ImportDomain.Main, null, 0); ISCTextEnum textEnum = GetTextEnum(ImportDomain.Main, new ScrReference(49, 0, 0, Paratext.ScrVers.English), new ScrReference(49, 1, 1, Paratext.ScrVers.English)); ISCTextSegment textSeg = textEnum.Next(); Assert.IsNotNull(textSeg, "Unable to read first segment"); Assert.AreEqual(@"\id", textSeg.Marker); Assert.AreEqual("EPH ", textSeg.Text); textSeg = textEnum.Next(); Assert.IsNotNull(textSeg); Assert.AreEqual(@"\mt", textSeg.Marker); Assert.AreEqual(49001000, textSeg.FirstReference.BBCCCVVV); textSeg = textEnum.Next(); Assert.IsNotNull(textSeg); Assert.AreEqual(@"\c", textSeg.Marker); Assert.AreEqual(49001001, textSeg.FirstReference.BBCCCVVV); textSeg = textEnum.Next(); Assert.IsNotNull(textSeg); Assert.AreEqual(@"\v", textSeg.Marker); Assert.AreEqual(49001001, textSeg.FirstReference.BBCCCVVV); Assert.AreEqual(" hello there ", textSeg.Text); Assert.IsNull(textEnum.Next()); } }
public void DataFileInvalid_NonExcludedMarkersBeforeIdLine() { using (TempSFFileMaker fileMaker = new TempSFFileMaker()) { string sFilename = fileMaker.CreateFileNoID( new string[] {@"\rem Ignore", @"\mt Genesis", @"\id GEN", @"\c 1", @"\v 1 Valid"}); // Try it first without strict checking to make sure it does not throw an exception ScrImportFileInfo fileInfo = new ScrImportFileInfo(sFilename, m_mappingList, ImportDomain.Main, null, 0); // Now use strict checking to make sure the error occurs. try { fileInfo.PerformStrictScan(); Assert.Fail("Failed to throw an exception."); } catch (ScriptureUtilsException e) { Assert.AreEqual(SUE_ErrorCode.UnexcludedDataBeforeIdLine, e.ErrorCode); } } }
public void TestInlineVerseNumberAfterParaMarker() { CheckDisposed(); using (TempSFFileMaker fileMaker = new TempSFFileMaker()) { string fileName = fileMaker.CreateFileNoID( new string[] { @"\id EPH", @"\mt Ephesians", @"\c 1", @"\p \v 1 hello there"}); // The import type for Individual Paratext 6 files is Paratext 5. m_settings.ImportTypeEnum = TypeOfImport.Paratext5; m_settings.AddFile(fileName, ImportDomain.Main, null, 0); ISCTextEnum textEnum = GetTextEnum(ImportDomain.Main, new ScrReference(49, 0, 0, Paratext.ScrVers.English), new ScrReference(49, 1, 1, Paratext.ScrVers.English)); ISCTextSegment textSeg = textEnum.Next(); Assert.IsNotNull(textSeg, "Unable to read first segment"); Assert.AreEqual(@"\id", textSeg.Marker); Assert.AreEqual("EPH ", textSeg.Text); textSeg = textEnum.Next(); Assert.IsNotNull(textSeg); Assert.AreEqual(@"\mt", textSeg.Marker); Assert.AreEqual("Ephesians ", textSeg.Text); Assert.AreEqual(49001000, textSeg.FirstReference.BBCCCVVV); textSeg = textEnum.Next(); Assert.IsNotNull(textSeg); Assert.AreEqual(@"\c", textSeg.Marker); Assert.AreEqual(" ", textSeg.Text); Assert.AreEqual(49001001, textSeg.FirstReference.BBCCCVVV); textSeg = textEnum.Next(); Assert.IsNotNull(textSeg); Assert.AreEqual(@"\p", textSeg.Marker); Assert.AreEqual(string.Empty, textSeg.Text); Assert.AreEqual(49001001, textSeg.FirstReference.BBCCCVVV); textSeg = textEnum.Next(); Assert.IsNotNull(textSeg); Assert.AreEqual(@"\v", textSeg.Marker); Assert.AreEqual(49001001, textSeg.FirstReference.BBCCCVVV); Assert.AreEqual(" hello there ", textSeg.Text); Assert.IsNull(textEnum.Next()); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Creates and loads a set of dummy converters to test the /// <see cref="CnvtrPropertiesCtrl"/> class. /// </summary> /// ------------------------------------------------------------------------------------ public override void FixtureSetup() { base.FixtureSetup(); m_fileMaker = new TempSFFileMaker(); m_myDlg = new DummyAddCnvtrDlg(); m_myCtrl = new DummyCnvtrPropertiesCtrl(); SilEncConverters31.EncConverters encConverters = new SilEncConverters31.EncConverters(); string[] ccFileContents = {"'c' > 'C'"}; m_ccFileName = m_fileMaker.CreateFileNoID(ccFileContents, "cct"); encConverters.AddConversionMap("ZZZTestCC", m_ccFileName, ConvType.Legacy_to_Unicode, "SIL.cc", "", "", ProcessTypeFlags.UnicodeEncodingConversion); string[] mapFileContents = { "EncodingName 'ZZZText'", "DescriptiveName 'Silly test file'", "ByteDefault '?'", "UniDefault replacement_character", "0x80 <> euro_sign" }; m_mapFileName = m_fileMaker.CreateFileNoID(mapFileContents, "map"); encConverters.AddConversionMap("ZZZTestMap", m_mapFileName, ConvType.Legacy_to_from_Unicode, "SIL.map", "", "", ProcessTypeFlags.UnicodeEncodingConversion); // TODO: Should test a legitimate compiled TecKit file by embedding a zipped // up one in the resources for testing purposes. // This is a randomly chosen ICU converter. The test may break when we reduce the set of // ICU converters we ship. encConverters.AddConversionMap("ZZZTestICU", "ISO-8859-1", ConvType.Legacy_to_from_Unicode, "ICU.conv", "", "", ProcessTypeFlags.UnicodeEncodingConversion); // Add a 1-step compound converter, which won't be any of the types our dialog // recognizes for now. encConverters.AddCompoundConverterStep("ZZZTestCompound", "ZZZTestCC", true, NormalizeFlags.None); // Load all the mappings after the dummy mappings are added, so the Converter // Mapping File combo box won't contain obsolete versions of the mappings referring // to old temp files from a previous run of the tests. m_myCtrl.CnvtrPropertiesCtrl_Load(null, null); encConverters.Remove("Bogus"); }
public void InlineVerseNumberAfterParaMarker() { TempSFFileMaker fileMaker = new TempSFFileMaker(); // WANTTESTPORT: (TE) Remove braces once no more integrations needed from FW_6.0 (indentation will force merge conflicts to prevent unintended changes) { string fileName = fileMaker.CreateFileNoID( new string[] { @"\id EPH", @"\mt Ephesians", @"\c 1", @"\p \v 1 hello there"}); // The import type for Individual Paratext 6 files is Paratext 5. m_settings.ImportTypeEnum = TypeOfImport.Paratext5; m_settings.AddFile(fileName, ImportDomain.Main, null, null); ISCTextEnum textEnum = GetTextEnum(ImportDomain.Main, new ScrReference(49, 0, 0, ScrVers.English), new ScrReference(49, 1, 1, ScrVers.English)); ISCTextSegment textSeg = textEnum.Next(); Assert.IsNotNull(textSeg, "Unable to read first segment"); Assert.AreEqual(@"\id", textSeg.Marker); Assert.AreEqual("EPH ", textSeg.Text); textSeg = textEnum.Next(); Assert.IsNotNull(textSeg); Assert.AreEqual(@"\mt", textSeg.Marker); Assert.AreEqual("Ephesians ", textSeg.Text); Assert.AreEqual(49001000, textSeg.FirstReference.BBCCCVVV); textSeg = textEnum.Next(); Assert.IsNotNull(textSeg); Assert.AreEqual(@"\c", textSeg.Marker); Assert.AreEqual(" ", textSeg.Text); Assert.AreEqual(49001001, textSeg.FirstReference.BBCCCVVV); textSeg = textEnum.Next(); Assert.IsNotNull(textSeg); Assert.AreEqual(@"\p", textSeg.Marker); Assert.AreEqual(string.Empty, textSeg.Text); Assert.AreEqual(49001001, textSeg.FirstReference.BBCCCVVV); textSeg = textEnum.Next(); Assert.IsNotNull(textSeg); Assert.AreEqual(@"\v", textSeg.Marker); Assert.AreEqual(49001001, textSeg.FirstReference.BBCCCVVV); Assert.AreEqual(" hello there ", textSeg.Text); Assert.IsNull(textEnum.Next()); } }
public void AddFilesWithoutBooks_User() { TempSFFileMaker fileMaker = new TempSFFileMaker(); string file1 = fileMaker.CreateFile("EPH", new string[] {@"\c 1", @"\v 1"}); string file2 = fileMaker.CreateFile("1CO", new string[] {@"\c 1", @"\v 1"}); string file3 = fileMaker.CreateFileNoID(new string[] {@"\_sh"}); // Make sure only two files were added m_builder.m_filenamesToAdd = new string[] {file1, file2, file3}; m_builder.ClickAddButton(); Assert.AreEqual(2, m_builder.ScriptureFiles.Count); Assert.AreEqual(2, m_builder.ScrListView.Items.Count); }
public void TestAddFile_Empty() { CheckDisposed(); m_importSettings.ImportTypeEnum = TypeOfImport.Other; TempSFFileMaker fileMaker = new TempSFFileMaker(); string filename = fileMaker.CreateFileNoID(new string[] {}); m_importSettings.AddFile(filename, ImportDomain.Main, null, 0); }