///<summary>
		/// This initializer is intended for tests as it allows setting of the basePath explicitly.
		///</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>
		internal static GlobalWritingSystemRepository InitializeWithBasePath(string basePath, LdmlVersion0MigrationStrategy.MigrationHandler migrationHandler)
		{
			lock (_padlock)
			{
				if (_instance == null)
				{
					var migrator = new GlobalWritingSystemRepositoryMigrator(basePath, migrationHandler);
					if (migrator.NeedsMigration())
					{
						migrator.Migrate();
					}

					_instance = new GlobalWritingSystemRepository(basePath);
					_instance.LoadAllDefinitions();
				}
			}
			return _instance;
		}
		public void Migrate_PalsoAndFlexHaveSameFileName_PrefersFlex()
		{
			using (var e = new TestEnvironment())
			{
				TestEnvironment.WritePalasoFile("qaa-x-bogus", "bogusPalaso", TestEnvironment.LdmlV0);
				TestEnvironment.WriteFlexFile("qaa-x-bogus", "bogusFlex", TestEnvironment.LdmlV0);
				var m = new GlobalWritingSystemRepositoryMigrator(e.BasePath, e.OnMigrateCallback);
				m.Migrate();

				Assert.AreEqual(WritingSystemDefinition.LatestWritingSystemDefinitionVersion, e.GetFileVersion("qaa-x-bogus.ldml"));
				AssertThatXmlIn.String(e.MigratedLdml("qaa-x-bogus.ldml")).HasAtLeastOneMatchForXpath(
					"ldml/special/palaso:abbreviation[@value='bogusFlex']",
					e.NamespaceManager
				);
			}
		}
		public void Migrate_WithCurrentFlexFile_FileCopiedToRepo()
		{
			using (var e = new TestEnvironment())
			{
				TestEnvironment.WriteFlexFile("qaa-x-bogus", "bogus", TestEnvironment.LdmlV1);
				var m = new GlobalWritingSystemRepositoryMigrator(e.BasePath, e.OnMigrateCallback);
				m.Migrate();

				Assert.AreEqual(WritingSystemDefinition.LatestWritingSystemDefinitionVersion, e.GetFileVersion("qaa-x-bogus.ldml"));
			}
		}