/* Ideally we would be able to preserve the 2 x's in compatibility mode. However we stopped short
  * of requiring the WritingSystemDefinition to hold info about malformed tags. So, in this case
  * it gets cleaned up (due to the call to parse in FindOrphans.
  */
 public void FindOrphans_FileContainsEntirelyPrivateUseRfcTagWithFlexStyleTwoX_RfcTagIsMigrated()
 {
     using (var e = new TestEnvironment("x-custom-Zxxx-x-audio", "x-dontcare"))
     {
         var wss = new List <string>(e.GetIdsFromFile);
         WritingSystemOrphanFinder.FindOrphans(wss, e.ReplaceIdInFile, e.WritingSystemRepository);
         Assert.That(e.FileContent, Is.EqualTo("|x-custom-Zxxx-audio||x-custom-Zxxx-audio||x-dontcare|"));
         Assert.That(e.WritingSystemRepository.Count, Is.EqualTo(2));
     }
 }
 public void FindOrphans_NoOrphansFound_WritingSystemRepoAndFileUntouched()
 {
     using (var e = new TestEnvironment("en", "en"))
     {
         var englishWs = new WritingSystemDefinition("en");
         e.WritingSystemRepository.Set(englishWs);
         WritingSystemOrphanFinder.FindOrphans(e.GetIdsFromFile, e.ReplaceIdInFile, e.WritingSystemRepository);
         Assert.That(e.WritingSystemRepository.Count, Is.EqualTo(1));
         Assert.That(e.WritingSystemRepository.Get("en"), Is.EqualTo(englishWs));
         Assert.That(e.FileContent, Is.EqualTo("|en||en||en|"));
     }
 }
 public void FindOrphans_StaticListOfIds_DuplicateIsCreated()
 {
     using (var e = new TestEnvironment("boglang-Zxxx-bogusws", "boglang-bogusws-Zxxx"))
     {
         var wss = new List <string>(e.GetIdsFromFile);
         WritingSystemOrphanFinder.FindOrphans(wss, e.ReplaceIdInFile, e.WritingSystemRepository);
         Assert.That(e.WritingSystemRepository.Count, Is.EqualTo(2));
         Assert.That(e.WritingSystemRepository.Get("qaa-Zxxx-x-boglang-bogusws"), Is.Not.Null);
         Assert.That(e.WritingSystemRepository.Get("qaa-Zxxx-x-boglang-bogusws-dupl0"), Is.Not.Null);
         Assert.That(e.FileContent, Is.EqualTo("|qaa-Zxxx-x-boglang-bogusws||qaa-Zxxx-x-boglang-bogusws||qaa-Zxxx-x-boglang-bogusws-dupl0|"));
     }
 }
 public void FindOrphans_OrphanFoundIsValidRfcTag_WritingsystemIsAddedToWritingSystemRepoAndFileUntouched()
 {
     using (var e = new TestEnvironment("en", "de"))
     {
         var englishWs = new WritingSystemDefinition("en");
         e.WritingSystemRepository.Set(englishWs);
         WritingSystemOrphanFinder.FindOrphans(e.GetIdsFromFile, e.ReplaceIdInFile, e.WritingSystemRepository);
         Assert.That(e.WritingSystemRepository.Count, Is.EqualTo(2));
         Assert.That(e.WritingSystemRepository.Get("en"), Is.EqualTo(englishWs));
         Assert.That(e.WritingSystemRepository.Get("de"), Is.Not.Null);
         Assert.That(e.FileContent, Is.EqualTo("|en||en||de|"));
     }
 }
 public void FindOrphans_OrphanFoundIsNotValidRfcTag_OrphanIsMadeConformAndIsAddedWritingSystemRepoAndWritingSystemIsChangedInFile()
 {
     using (var e = new TestEnvironment("en", "bogusws"))
     {
         var englishWs = new WritingSystemDefinition("en");
         e.WritingSystemRepository.Set(englishWs);
         WritingSystemOrphanFinder.FindOrphans(e.GetIdsFromFile, e.ReplaceIdInFile, e.WritingSystemRepository);
         Assert.That(e.WritingSystemRepository.Count, Is.EqualTo(2));
         Assert.That(e.WritingSystemRepository.Get("en"), Is.EqualTo(englishWs));
         Assert.That(e.WritingSystemRepository.Get("qaa-x-bogusws"), Is.Not.Null);
         Assert.That(e.FileContent, Is.EqualTo("|en||en||qaa-x-bogusws|"));
     }
 }
 public void FindOrphans_OrphanFoundIsNotValidRfcTagButWritingSystemRepoKnowsAboutChange_WritingSystemIsChangedInFile()
 {
     using (var e = new TestEnvironment("en", "bogusws"))
     {
         var englishWs = new WritingSystemDefinition("en");
         e.WritingSystemRepository.Set(englishWs);
         e.WritingSystemRepository.Save();
         englishWs.Variants.Add("new");
         e.WritingSystemRepository.Set(englishWs);
         e.WritingSystemRepository.Save();
         WritingSystemOrphanFinder.FindOrphans(e.GetIdsFromFile, e.ReplaceIdInFile, e.WritingSystemRepository);
         Assert.That(e.WritingSystemRepository.Count, Is.EqualTo(2));
         Assert.That(e.WritingSystemRepository.Get("en-x-new"), Is.EqualTo(englishWs));
         Assert.That(e.WritingSystemRepository.Get("qaa-x-bogusws"), Is.Not.Null);
         Assert.That(e.FileContent, Is.EqualTo("|en-x-new||en-x-new||qaa-x-bogusws|"));
     }
 }
 public void CreateNonExistentWritingSystemsFoundInFile()
 {
     WritingSystemOrphanFinder.FindOrphans(WritingSystemsInUse, ReplaceWritingSystemId, _writingSystemRepository);
 }
Пример #8
0
 public void CreateWritingSystemsForIdsInFileWhereNecassary(IWritingSystemRepository writingSystemRepository)
 {
     WritingSystemOrphanFinder.FindOrphans(WritingSystemsInUse, ReplaceWritingSystemId, writingSystemRepository);
 }