public void PerformMigration(IDomainObjectDTORepository repoDto) { DataMigrationServices.CheckVersionNumber(repoDto, 7000043); if (repoDto.ProjectFolder != Path.GetTempPath()) { // Skip migrating the global repository if we're just running tests. Slow and may not be wanted. // In a real project we do this first; thus if by any chance a WS is differently renamed in // the two folders, the renaming that is right for this project wins. var globalWsFolder = DirectoryFinder.GlobalWritingSystemStoreDirectory; var globalMigrator = new LdmlInFolderWritingSystemRepositoryMigrator(globalWsFolder, NoteMigration); globalMigrator.Migrate(); } var ldmlFolder = Path.Combine(repoDto.ProjectFolder, FdoFileHelper.ksWritingSystemsDir); var migrator = new LdmlInFolderWritingSystemRepositoryMigrator(ldmlFolder, NoteMigration); migrator.Migrate(); UpdateTags(repoDto); DataMigrationServices.IncrementVersionNumber(repoDto); }
///<summary> /// Returns an instance of an ldml in folder writing system reposistory. ///</summary> ///<param name="basePath">base location of the global writing system repository</param> ///<param name="migrationHandler">Callback if during the initialization any writing system id's are changed</param> ///<param name="loadProblemHandler">Callback if during the initialization any writing systems cannot be loaded</param> ///<param name="compatibilityMode"></param> public static LdmlInFolderWritingSystemRepository Initialize( string basePath, LdmlVersion0MigrationStrategy.MigrationHandler migrationHandler, WritingSystemLoadProblemHandler loadProblemHandler, WritingSystemCompatibility compatibilityMode ) { var migrator = new LdmlInFolderWritingSystemRepositoryMigrator(basePath, migrationHandler, compatibilityMode); migrator.Migrate(); var instance = new LdmlInFolderWritingSystemRepository(basePath, compatibilityMode); instance.LoadAllDefinitions(); // Call the loadProblemHandler with both migration problems and load problems var loadProblems = new List<WritingSystemRepositoryProblem>(); loadProblems.AddRange(migrator.MigrationProblems); loadProblems.AddRange(instance.LoadProblems); if (loadProblems.Count > 0 && loadProblemHandler != null) { loadProblemHandler(loadProblems); } return instance; }
static int Main(string[] rgArgs) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); for (int i = 0; i < rgArgs.Length; ++i) { if (rgArgs[i] == "-debug") s_fDebug = true; else if (rgArgs[i] == "-autoclose") s_fAutoClose = true; else if (rgArgs[i] == "-chars") s_fMigrateChars = true; } RegistryHelper.ProductName = "FieldWorks"; // needed to access proper registry values if (s_fMigrateChars && s_fDebug) MessageBox.Show("Warning: MigrateSqlDbs called with no-longer valid argument, '-chars'. Run 'UnicodeCharEditor -i' instead."); // TE-9422. If we had an older version of FW7 installed, ldml files are < verion 2, so will cause // a crash if we don't migrate the files to version 2 before opening a project with the current version. string globalWsFolder = DirectoryFinder.GlobalWritingSystemStoreDirectory; var globalMigrator = new LdmlInFolderWritingSystemRepositoryMigrator(globalWsFolder, NoteMigration); globalMigrator.Migrate(); using (var threadHelper = new ThreadHelper()) using (var progressDlg = new ProgressDialogWithTask(threadHelper)) { ImportFrom6_0 importer = new ImportFrom6_0(progressDlg, FwDirectoryFinder.ConverterConsoleExe, FwDirectoryFinder.DbExe, s_fDebug); if (!importer.IsFwSqlServerInstalled()) return -1; string version; if (!importer.IsValidOldFwInstalled(out version)) { if (!String.IsNullOrEmpty(version) && version.CompareTo("5.4") < 0) { string launchesFlex = "0"; string launchesTE = "0"; if (RegistryHelper.KeyExists(FwRegistryHelper.FieldWorksRegistryKey, "Language Explorer")) { using (RegistryKey keyFlex = FwRegistryHelper.FieldWorksRegistryKey.CreateSubKey("Language Explorer")) launchesFlex = keyFlex.GetValue("launches", "0") as string; } if (RegistryHelper.KeyExists(FwRegistryHelper.FieldWorksRegistryKey, FwSubKey.TE)) { using (RegistryKey keyTE = FwRegistryHelper.FieldWorksRegistryKey.CreateSubKey(FwSubKey.TE)) launchesTE = keyTE.GetValue("launches", "0") as string; } if (launchesFlex == "0" && launchesTE == "0") { FwRegistryHelper.FieldWorksRegistryKey.SetValue("MigrationTo7Needed", "true"); } using (var dlg = new FWVersionTooOld(version)) { dlg.ShowDialog(); } } return -1; } List<string> projects = GetProjectList(); if (projects.Count > 0) { using (var migrateProjects = new MigrateProjects(importer, version, projects, s_fAutoClose)) { Application.Run(migrateProjects); } } else if (s_fDebug) { MessageBox.Show("No FieldWorks (SQL) projects were detected.", "DEBUG!"); } } return s_ReturnValue; }
public void Migrate_LanguageSubtagEndsInDashXDash_DashXDashIsRemoved() { using (var environment = new TestEnvironment()) { environment.WriteLdmlFile("test.ldml", LdmlContentForTests.Version0("en-x-", "", "", "")); var migrator = new LdmlInFolderWritingSystemRepositoryMigrator(environment.LdmlPath, environment.OnMigrateCallback); migrator.Migrate(); AssertLdmlHasXpath(environment.MappedFilePath("test.ldml"), "/ldml/identity/language[@type='en']"); } }
public void Migrate_ScriptSubtagContainsValidSubtagWithPrecedingX_ScriptSubtagIsSetToValidSubtag() { using (var environment = new TestEnvironment()) { environment.WriteLdmlFile("test.ldml", LdmlContentForTests.Version0("", "x-latn", "", "")); var migrator = new LdmlInFolderWritingSystemRepositoryMigrator(environment.LdmlPath, environment.OnMigrateCallback); migrator.Migrate(); AssertLdmlHasXpath(environment.MappedFilePath("test.ldml"), "/ldml/identity/script[@type='latn']"); } }
public void Migrate_LanguageSubtagContainsValidSubtagWithPrecedingX_IsChangedToNonPrivateUse() { using (var environment = new TestEnvironment()) { environment.WriteLdmlFile("x-en.ldml", LdmlContentForTests.Version0("x-en", "", "", "")); var migrator = new LdmlInFolderWritingSystemRepositoryMigrator(environment.LdmlPath, environment.OnMigrateCallback); migrator.Migrate(); AssertLdmlHasXpath(environment.MappedFilePath("x-en.ldml"), "/ldml/identity/language[@type='qaa']"); AssertLdmlHasXpath(environment.MappedFilePath("x-en.ldml"), "/ldml/identity/variant[@type='x-en']"); } }
public void Migrate_LdmlIsVersion0_IsLatestVersion() { using (var environment = new TestEnvironment()) { environment.WriteLdmlFile("test.ldml", LdmlContentForTests.Version0English()); var migrator = new LdmlInFolderWritingSystemRepositoryMigrator(environment.LdmlPath, environment.OnMigrateCallback); migrator.Migrate(); var versionGetter = new WritingSystemLdmlVersionGetter(); Assert.AreEqual(2, versionGetter.GetFileVersion(environment.MappedFilePath("test.ldml"))); } }
public void Migrate_OriginalFileIsNotVersionThatWeCanMigrate_Throws() { using (var environment = new TestEnvironment()) { environment.WriteLdmlFile("test.ldml", LdmlContentForTests.Version99Default()); var migrator = new LdmlInFolderWritingSystemRepositoryMigrator(environment.LdmlPath, environment.OnMigrateCallback); Assert.Throws<InvalidOperationException>(migrator.Migrate); } }
public void Migrate_LanguageSubtagAndRegionSubtagContainValidDuplicates_DataIsNotDuplicatedInPrivateUse() { using (var environment = new TestEnvironment()) { environment.WriteLdmlFile("test.ldml", LdmlContentForTests.Version0("de", "", "DE", "")); var migrator = new LdmlInFolderWritingSystemRepositoryMigrator(environment.LdmlPath, environment.OnMigrateCallback); migrator.Migrate(); AssertLdmlHasXpath(environment.MappedFilePath("test.ldml"), "/ldml/identity/language[@type='de']"); AssertLdmlHasXpath(environment.MappedFilePath("test.ldml"), "/ldml/identity/territory[@type='DE']"); AssertLdmlHasNoXpath(environment.MappedFilePath("test.ldml"), "/ldml/identity/variant"); } }
public void Migrate_VariantContainsDuplicate_DuplicateIsmovedToPrivateUse() { using (var environment = new TestEnvironment()) { environment.WriteLdmlFile("test.ldml", LdmlContentForTests.Version0("en", "", "", "biske-BiSKe")); var migrator = new LdmlInFolderWritingSystemRepositoryMigrator(environment.LdmlPath, environment.OnMigrateCallback); migrator.Migrate(); AssertLdmlHasXpath(environment.MappedFilePath("test.ldml"), "/ldml/identity/variant[@type='biske-x-BiSKe']"); } }
public void Migrate_LanguageSubtagContainsDatathatIsNotValidLanguageScriptRegionOrVariantAndIsDuplicateOfDataInPrivateUse_DataIsNotDuplicatedInPrivateUse() { using (var environment = new TestEnvironment()) { environment.WriteLdmlFile("test.ldml", LdmlContentForTests.Version0("en-bogus", "", "", "x-BoGuS-stuff")); var migrator = new LdmlInFolderWritingSystemRepositoryMigrator(environment.LdmlPath, environment.OnMigrateCallback); migrator.Migrate(); AssertLdmlHasXpath(environment.MappedFilePath("test.ldml"), "/ldml/identity/language[@type='en']"); AssertLdmlHasXpath(environment.MappedFilePath("test.ldml"), "/ldml/identity/variant[@type='x-bogus-stuff']"); } }
public void Migrate_RegionContainsTagThatIsValidRegion_IsMigrated() { using (var environment = new TestEnvironment()) { environment.WriteLdmlFile("test.ldml", LdmlContentForTests.Version0("en", "", "DE", "")); var migrator = new LdmlInFolderWritingSystemRepositoryMigrator(environment.LdmlPath, environment.OnMigrateCallback); migrator.Migrate(); AssertLdmlHasXpath(environment.MappedFilePath("test.ldml"), "/ldml/identity/language[@type='en']"); AssertLdmlHasXpath(environment.MappedFilePath("test.ldml"), "/ldml/identity/territory[@type='DE']"); } }
public void Migrate_RegionSubtagContainsAnythingButValidRegion_InvalidContentIsMovedToPrivateUse() { using (var environment = new TestEnvironment()) { environment.WriteLdmlFile("test.ldml", LdmlContentForTests.Version0("qaa", "", "bogus-stuff", "")); var migrator = new LdmlInFolderWritingSystemRepositoryMigrator(environment.LdmlPath, environment.OnMigrateCallback); migrator.Migrate(); AssertLdmlHasXpath(environment.MappedFilePath("test.ldml"), "/ldml/identity/territory[@type='QM']"); AssertLdmlHasXpath(environment.MappedFilePath("test.ldml"), "/ldml/identity/variant[@type='x-bogus-stuff']"); } }
public void Migrate_ScriptSubtagContainsMultipleValidScriptSubtagsAsWellAsDataThatIsNotValidScriptAsWellAsAudio_NonValidDataisMovedToPrivateUseAsScriptIsZxxx() { using (var environment = new TestEnvironment()) { environment.WriteLdmlFile("test.ldml", LdmlContentForTests.Version0("", "x-bogus-Latn-audio-Afak-bogus2-x-", "", "")); var migrator = new LdmlInFolderWritingSystemRepositoryMigrator(environment.LdmlPath, environment.OnMigrateCallback); migrator.Migrate(); AssertLdmlHasXpath(environment.MappedFilePath("test.ldml"), "/ldml/identity/script[@type='Zxxx']"); AssertLdmlHasXpath(environment.MappedFilePath("test.ldml"), "/ldml/identity/variant[@type='x-bogus-audio-bogus2-Afak-Latn']"); } }
public void Migrate_LanguageSubtagContainsMultipleValidLanguageSubtagsAsWellAsDataThatIsNotValidLanguageScriptRegionOrVariant_AllSubtagsButFirstValidLanguageSubtagAreMovedToPrivateUse() { using (var environment = new TestEnvironment()) { environment.WriteLdmlFile("test.ldml", LdmlContentForTests.Version0("bogus-en-audio-tpi-bogus2-x-", "", "", "")); var migrator = new LdmlInFolderWritingSystemRepositoryMigrator(environment.LdmlPath, environment.OnMigrateCallback); migrator.Migrate(); AssertLdmlHasXpath(environment.MappedFilePath("test.ldml"), "/ldml/identity/variant[@type='x-bogus-audio-bogus2-tpi']"); } }
public void Migrate_DateModified_IsLaterThanBeforeMigration() { using (var environment = new TestEnvironment()) { environment.WriteLdmlFile( "test.ldml", LdmlContentForTests.Version0WithAllSortsOfDatathatdoesNotNeedSpecialAttention("", "", "", "")); var wsV0 = new WritingSystemDefinitionV0(); new LdmlAdaptorV0().Read(environment.FilePath("test.ldml"), wsV0); DateTime dateBeforeMigration = wsV0.DateModified; var migrator = new LdmlInFolderWritingSystemRepositoryMigrator(environment.LdmlPath, environment.OnMigrateCallback); migrator.Migrate(); var wsV1= new WritingSystemDefinitionV1(); new LdmlAdaptorV1().Read(environment.MappedFilePath("test.ldml"), wsV1); DateTime dateAfterMigration = wsV1.DateModified; Assert.IsTrue(dateAfterMigration > dateBeforeMigration); } }
public void Migrate_LanguageSubtagContainsOnlyInvalidData_DataIsMovedToPrivateUseAndLanguageSubtagIsSetToQaa() { using (var environment = new TestEnvironment()) { environment.WriteLdmlFile("test.ldml", LdmlContentForTests.Version0("bogus-stuff", "", "", "")); var migrator = new LdmlInFolderWritingSystemRepositoryMigrator(environment.LdmlPath, environment.OnMigrateCallback); migrator.Migrate(); AssertLdmlHasXpath(environment.MappedFilePath("test.ldml"), "/ldml/identity/language[@type='qaa']"); AssertLdmlHasXpath(environment.MappedFilePath("test.ldml"), "/ldml/identity/variant[@type='x-bogus-stuff']"); } }
public void Migrate_LanguageNameIsNotSet_LanguageNameIsSetToWhatIanaSubtagRegistrySays() { using (var environment = new TestEnvironment()) { environment.WriteLdmlFile("test.ldml", LdmlContentForTests.Version0WithLanguageSubtagAndName("en", String.Empty)); var migrator = new LdmlInFolderWritingSystemRepositoryMigrator(environment.LdmlPath, environment.OnMigrateCallback); migrator.Migrate(); AssertThatXmlIn.File(environment.MappedFilePath("test.ldml")). HasAtLeastOneMatchForXpath("/ldml/special/palaso:languageName[@value = 'English']", environment.NamespaceManager); } }
public void Migrate_LanguageSubtagContainsSubtagThatIsToLongForPrivateUse_SubtagIsTruncated() { using (var environment = new TestEnvironment()) { environment.WriteLdmlFile("test.ldml", LdmlContentForTests.Version0("en", "", "", "x-bogusstuffistolong")); var migrator = new LdmlInFolderWritingSystemRepositoryMigrator(environment.LdmlPath, environment.OnMigrateCallback); migrator.Migrate(); AssertLdmlHasXpath(environment.MappedFilePath("test.ldml"), "/ldml/identity/language[@type='en']"); AssertLdmlHasXpath(environment.MappedFilePath("test.ldml"), "/ldml/identity/variant[@type='x-bogusstu']"); } }
public void Migrate_WritingSystemRepositoryContainsWsThatWouldBeMigratedToDuplicateOfExistingWs_DuplicateWsAreDisambiguated() { using (var environment = new TestEnvironment()) { environment.WriteLdmlFile("en-Zxxx-x-audio.ldml", LdmlContentForTests.Version0("en", "Zxxx", "", "x-audio")); environment.WriteLdmlFile("en-x-audio.ldml", LdmlContentForTests.Version0("en", "", "", "x-audio")); var migrator = new LdmlInFolderWritingSystemRepositoryMigrator(environment.LdmlPath, environment.OnMigrateCallback); migrator.Migrate(); Assert.True(File.Exists(environment.MappedFilePath("en-Zxxx-x-audio.ldml"))); Assert.True(File.Exists(environment.MappedFilePath("en-x-audio.ldml"))); AssertLdmlHasXpath(environment.MappedFilePath("en-Zxxx-x-audio.ldml"), "/ldml/identity/language[@type='en']"); AssertLdmlHasXpath(environment.MappedFilePath("en-Zxxx-x-audio.ldml"), "/ldml/identity/script[@type='Zxxx']"); AssertLdmlHasXpath(environment.MappedFilePath("en-Zxxx-x-audio.ldml"), "/ldml/identity/variant[@type='x-audio']"); AssertLdmlHasXpath(environment.MappedFilePath("en-x-audio.ldml"), "/ldml/identity/language[@type='en']"); AssertLdmlHasXpath(environment.MappedFilePath("en-x-audio.ldml"), "/ldml/identity/script[@type='Zxxx']"); AssertLdmlHasXpath(environment.MappedFilePath("en-x-audio.ldml"), "/ldml/identity/variant[@type='x-audio-dupl1']"); } }
public void Migrate_LanguageSubtagContainsDuplicatePrivateUse_DuplicateIsRemoved() { using (var environment = new TestEnvironment()) { environment.WriteLdmlFile("test.ldml", LdmlContentForTests.Version0("bogus", "", "", "x-bogus")); var migrator = new LdmlInFolderWritingSystemRepositoryMigrator(environment.LdmlPath, environment.OnMigrateCallback); migrator.Migrate(); AssertLdmlHasXpath(environment.MappedFilePath("test.ldml"), "/ldml/identity/language[@type='qaa']"); AssertLdmlHasXpath(environment.MappedFilePath("test.ldml"), "/ldml/identity/variant[@type='x-bogus']"); } }
public void Migrate_ScriptSubtagContainsExcessiveXs_XsAreIgnoredAndNonIanaConformDataIsWrittenToPrivateUse() { using (var environment = new TestEnvironment()) { environment.WriteLdmlFile("test.ldml", LdmlContentForTests.Version0("", "x-Latn-x-test", "", "")); var migrator = new LdmlInFolderWritingSystemRepositoryMigrator(environment.LdmlPath, environment.OnMigrateCallback); migrator.Migrate(); AssertLdmlHasXpath(environment.MappedFilePath("test.ldml"), "/ldml/identity/script[@type='Latn']"); AssertLdmlHasXpath(environment.MappedFilePath("test.ldml"), "/ldml/identity/variant[@type='x-test']"); } }
public void Migrate_VariantSubtagContainsAnythingButValidVariantOrprivateUseAndIsDuplicateOfDataInPrivateUse_DataIsNotDuplicatedInPrivateUse() { using (var environment = new TestEnvironment()) { environment.WriteLdmlFile("test.ldml", LdmlContentForTests.Version0("", "", "", "bogus-stuff-x-bogus")); var migrator = new LdmlInFolderWritingSystemRepositoryMigrator(environment.LdmlPath, environment.OnMigrateCallback); migrator.Migrate(); AssertLdmlHasXpath(environment.MappedFilePath("test.ldml"), "/ldml/identity/variant[@type='x-bogus-stuff']"); } }
public void Migrate_LanguageSubtagInLdmlIsEmpty_LanguageSubtagIsSetToQaa() { using (var environment = new TestEnvironment()) { environment.WriteLdmlFile("test.ldml", LdmlContentForTests.Version0("", "", "", "")); var migrator = new LdmlInFolderWritingSystemRepositoryMigrator(environment.LdmlPath, environment.OnMigrateCallback); migrator.Migrate(); AssertLdmlHasXpath(environment.MappedFilePath("test.ldml"), "/ldml/identity/language[@type='qaa']"); } }
public void Migrate_OriginalFileContainsLdmlDataWeDontCareAbout_DataIsCopied() { using (var environment = new TestEnvironment()) { environment.WriteLdmlFile("test.ldml", LdmlContentForTests.Version0WithLdmlInfoWeDontCareAbout("","","","")); var migrator = new LdmlInFolderWritingSystemRepositoryMigrator(environment.LdmlPath, environment.OnMigrateCallback); migrator.Migrate(); AssertLdmlHasXpath(environment.MappedFilePath("test.ldml"), "/ldml/identity/language[@type='qaa']"); AssertLdmlHasXpath(environment.MappedFilePath("test.ldml"), "/ldml/fallback/testing[text()='fallback']"); AssertLdmlHasXpath(environment.MappedFilePath("test.ldml"), "/ldml/layout/testing[text()='layout']"); AssertLdmlHasXpath(environment.MappedFilePath("test.ldml"), "/ldml/characters/testing[text()='characters']"); AssertLdmlHasXpath(environment.MappedFilePath("test.ldml"), "/ldml/delimiters/testing[text()='delimiters']"); AssertLdmlHasXpath(environment.MappedFilePath("test.ldml"), "/ldml/measurement/testing[text()='measurement']"); AssertLdmlHasXpath(environment.MappedFilePath("test.ldml"), "/ldml/dates/testing[text()='dates']"); AssertLdmlHasXpath(environment.MappedFilePath("test.ldml"), "/ldml/numbers/testing[text()='numbers']"); AssertLdmlHasXpath(environment.MappedFilePath("test.ldml"), "/ldml/units/testing[text()='units']"); AssertLdmlHasXpath(environment.MappedFilePath("test.ldml"), "/ldml/listPatterns/testing[text()='listPatterns']"); AssertLdmlHasXpath(environment.MappedFilePath("test.ldml"), "/ldml/posix/testing[text()='posix']"); AssertLdmlHasXpath(environment.MappedFilePath("test.ldml"), "/ldml/segmentations/testing[text()='segmentations']"); AssertLdmlHasXpath(environment.MappedFilePath("test.ldml"), "/ldml/rbnf/testing[text()='rbnf']"); AssertLdmlHasXpath(environment.MappedFilePath("test.ldml"), "/ldml/references/testing[text()='references']"); } }
public void Migrate_OriginalFileContainsAllSortsOfDataThatShouldJustBeCopiedOver_DataIsMigrated() { using (var environment = new TestEnvironment()) { environment.WriteLdmlFile( "test.ldml", LdmlContentForTests.Version0WithAllSortsOfDatathatdoesNotNeedSpecialAttention("", "", "", "")); var migrator = new LdmlInFolderWritingSystemRepositoryMigrator(environment.LdmlPath, environment.OnMigrateCallback); migrator.Migrate(); AssertThatXmlIn.File(environment.MappedFilePath("test.ldml")). HasAtLeastOneMatchForXpath("/ldml/special/palaso:defaultFontFamily[@value='Arial']", environment.NamespaceManager); AssertThatXmlIn.File(environment.MappedFilePath("test.ldml")). HasAtLeastOneMatchForXpath("/ldml/special/palaso:defaultFontSize[@value='12']", environment.NamespaceManager); AssertThatXmlIn.File(environment.MappedFilePath("test.ldml")). HasAtLeastOneMatchForXpath("/ldml/special/palaso:abbreviation[@value='la']", environment.NamespaceManager); AssertThatXmlIn.File(environment.MappedFilePath("test.ldml")). HasAtLeastOneMatchForXpath("/ldml/special/palaso:isLegacyEncoded[@value='True']", environment.NamespaceManager); AssertThatXmlIn.File(environment.MappedFilePath("test.ldml")). HasAtLeastOneMatchForXpath("/ldml/special/palaso:defaultKeyboard[@value='bogusKeyboard']", environment.NamespaceManager); AssertThatXmlIn.File(environment.MappedFilePath("test.ldml")). HasAtLeastOneMatchForXpath("/ldml/special/palaso:spellCheckingId[@value='ol']", environment.NamespaceManager); } }
public void Migrate_LdmlContainsWritingSystemThatIsVersion0_MigratedToLatest() { using (var environment = new TestEnvironment()) { const string fileName = "en-Zxxx-x-audio.ldml"; environment.WriteLdmlFile(fileName, LdmlContentForTests.Version0("en", "Zxxx", "", "x-audio")); var migrator = new LdmlInFolderWritingSystemRepositoryMigrator(environment.LdmlPath, environment.OnMigrateCallback); migrator.Migrate(); Assert.AreEqual(2, environment.GetFileVersion(fileName)); } }
private void MigrateLdmlInFolder() { var migrator = new LdmlInFolderWritingSystemRepositoryMigrator(CurrentVersionPath, _migrationHandler, WritingSystemCompatibility.Strict); migrator.Migrate(); }
public void Migrate_OriginalFileContainsCustomIcuCollationInfo_CollationInfoIsMigrated() { using (var environment = new TestEnvironment()) { environment.WriteLdmlFile( "test.ldml", LdmlContentForTests.Version0WithCollationInfo(WritingSystemDefinitionV0.SortRulesType.CustomICU)); var wsV0 = new WritingSystemDefinitionV0(); new LdmlAdaptorV0().Read(environment.FilePath("test.ldml"), wsV0); var migrator = new LdmlInFolderWritingSystemRepositoryMigrator(environment.LdmlPath, environment.OnMigrateCallback); migrator.Migrate(); var wsV1 = new WritingSystemDefinitionV1(); new LdmlAdaptorV1().Read(environment.MappedFilePath("test.ldml"), wsV1); Assert.AreEqual(wsV0.SortRules, wsV1.SortRules); Assert.AreEqual(Enum.GetName(typeof(WritingSystemDefinitionV0.SortRulesType), wsV0.SortUsing), Enum.GetName(typeof(WritingSystemDefinitionV1.SortRulesType), wsV0.SortUsing)); } }
public void Migrate_LanguageSubtagContainsx_xIsNotDuplicated() { using (var environment = new TestEnvironment()) { environment.WriteLdmlFile("test.ldml", LdmlContentForTests.Version0("en-x-audio", String.Empty, String.Empty, "x-test")); var migrator = new LdmlInFolderWritingSystemRepositoryMigrator(environment.LdmlPath, environment.OnMigrateCallback); migrator.Migrate(); AssertLdmlHasXpath(environment.MappedFilePath("test.ldml"), "/ldml/identity/language[@type='en']"); AssertLdmlHasXpath(environment.MappedFilePath("test.ldml"), "/ldml/identity/variant[@type='x-audio-test']"); } }