Пример #1
0
        /// ------------------------------------------------------------------------------------
        /// <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");
        }
Пример #2
0
        public void SelectMapping_BogusCompiledTecKitFile()
        {
            string sFileName = m_fileMaker.CreateFileNoID(new string[] { "bogus contents" }, "tec");

            // This is a type we don't recognize.
            m_myDlg.m_cnvtrPropertiesCtrl.txtName.Text = "BogusTecKitFile";

            int i;

            for (i = 0; i < m_myDlg.m_cnvtrPropertiesCtrl.cboConverter.Items.Count; ++i)
            {
                if (((CnvtrTypeComboItem)m_myDlg.m_cnvtrPropertiesCtrl.cboConverter.Items[i]).Type == ConverterType.ktypeTecKitTec)
                {
                    m_myDlg.m_cnvtrPropertiesCtrl.cboConverter.SelectedIndex = i;
                    break;
                }
            }
            Assert.IsTrue(i < m_myDlg.m_cnvtrPropertiesCtrl.cboConverter.Items.Count);
            for (i = 0; i < m_myDlg.m_cnvtrPropertiesCtrl.cboConversion.Items.Count; ++i)
            {
                if (((CnvtrDataComboItem)m_myDlg.m_cnvtrPropertiesCtrl.cboConversion.Items[i]).Type == ConvType.Legacy_to_Unicode)
                {
                    m_myDlg.m_cnvtrPropertiesCtrl.cboConversion.SelectedIndex = i;
                    break;
                }
            }
            Assert.IsTrue(i < m_myDlg.m_cnvtrPropertiesCtrl.cboConversion.Items.Count);

            m_myDlg.SetMappingFile(sFileName);

            Assert.IsFalse(m_myDlg.InstallConverter());
            // This may not be testing what we want it to test...
            // Might want make an assert on the error message that is produced!
        }
        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);
        }