Exemple #1
0
        public void FixtureSetup()
        {
            var encConverters = new EncConverters();

            // Remove any encoding converters we created that have been left over due to a crash
            // or other mishap.  (That's why we use wierd names starting with ZZZUnitTest, so
            // there won't be any conceivable conflict with user chosen names.  Inconceivable
            // conflicts might still happen, but...)
            RemoveTestConverters(encConverters, "Installed mappings before test setup:");
            string[] ccFileContents = { "'c' > 'C'" };
            m_ccFileName = CreateTempFile(ccFileContents, "cct");
            encConverters.AddConversionMap("ZZZUnitTestCC", m_ccFileName,
                                           ConvType.Legacy_to_Unicode, "SIL.cc", "", "",
                                           ProcessTypeFlags.UnicodeEncodingConversion);

            string[] mapFileContents =
            {
                "EncodingName	'ZZZUnitTestText'",
                "DescriptiveName	'Silly test file'",
                "ByteDefault		'?'",
                "UniDefault		replacement_character",
                "0x80	<>	euro_sign"
            };
            m_mapFileName = CreateTempFile(mapFileContents, "map");
            encConverters.AddConversionMap("ZZZUnitTestMap", 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("ZZZUnitTestICU", "ISO-8859-1",
                                           ConvType.Legacy_to_from_Unicode, "ICU.conv", "", "",
                                           ProcessTypeFlags.ICUConverter);

            // Add a 1-step compound converter, which won't be any of the types our dialog
            // recognizes for now.
            encConverters.AddCompoundConverterStep("ZZZUnitTestCompound", "ZZZUnitTestCC", true,
                                                   NormalizeFlags.None);

            encConverters.Remove("BogusTecKitFile");                    // shouldn't exist, but...

            m_myDlg             = new DummyAddCnvtrDlg();
            m_myCtrl            = new DummyCnvtrPropertiesCtrl();
            m_myCtrl.Converters = encConverters;
            // 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.q
            m_myCtrl.CnvtrPropertiesCtrl_Load(null, null);
#if !QUIET
            Console.WriteLine("Installed mappings after test setup:");
            foreach (var name in encConverters.Mappings)
            {
                var conv = encConverters[name];
                Console.WriteLine("    {0} ({1})", name, conv == null ? "null" : conv.GetType().ToString());
            }
#endif
        }
Exemple #2
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");
        }
		/// ------------------------------------------------------------------------------------
		/// <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");
		}
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Creates and loads a set of dummy converters to test the
		/// <see cref="CnvtrPropertiesCtrl"/> class.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public override void FixtureSetup()
		{
			base.FixtureSetup();

			var encConverters = new EncConverters();
			// Remove any encoding converters we created that have been left over due to a crash
			// or other mishap.  (That's why we use wierd names starting with ZZZUnitTest, so
			// there won't be any conceivable conflict with user chosen names.  Inconceivable
			// conflicts might still happen, but...)
			RemoveTestConverters(encConverters, "Installed mappings before test setup:");
			string[] ccFileContents = {"'c' > 'C'"};
			m_ccFileName = CreateTempFile(ccFileContents, "cct");
			encConverters.AddConversionMap("ZZZUnitTestCC", m_ccFileName,
				ConvType.Legacy_to_Unicode, "SIL.cc", "", "",
				ProcessTypeFlags.UnicodeEncodingConversion);

			string[] mapFileContents = {
										   "EncodingName	'ZZZUnitTestText'",
										   "DescriptiveName	'Silly test file'",
										   "ByteDefault		'?'",
										   "UniDefault		replacement_character",
										   "0x80	<>	euro_sign"
									   };
			m_mapFileName = CreateTempFile(mapFileContents, "map");
			encConverters.AddConversionMap("ZZZUnitTestMap", 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("ZZZUnitTestICU", "ISO-8859-1",
				ConvType.Legacy_to_from_Unicode, "ICU.conv", "", "",
				ProcessTypeFlags.ICUConverter);

			// Add a 1-step compound converter, which won't be any of the types our dialog
			// recognizes for now.
			encConverters.AddCompoundConverterStep("ZZZUnitTestCompound", "ZZZUnitTestCC", true,
				NormalizeFlags.None);

			encConverters.Remove("BogusTecKitFile");	// shouldn't exist, but...

			m_myDlg = new DummyAddCnvtrDlg();
			m_myCtrl = new DummyCnvtrPropertiesCtrl();
			m_myCtrl.Converters = encConverters;
			// 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.q
			m_myCtrl.CnvtrPropertiesCtrl_Load(null, null);
#if !QUIET
			Console.WriteLine("Installed mappings after test setup:");
			foreach (var name in encConverters.Mappings)
			{
				var conv = encConverters[name];
				Console.WriteLine("    {0} ({1})", name, conv == null ? "null" : conv.GetType().ToString());
			}
#endif
		}