public void CompleteTagConstructor_QaaWithXDashBeforeValidLanguageName_NoChange() { var cleaner = new IetfLanguageTagCleaner("qaa-x-th"); cleaner.Clean(); Assert.That(cleaner.GetCompleteTag(), Is.EqualTo("qaa-x-th")); Assert.That(cleaner.Language, Is.EqualTo("qaa")); Assert.That(cleaner.PrivateUse, Is.EqualTo("th")); }
public void CompleteTagConstructor_InvalidLanguageNameWithScript_QaaAdded() { var cleaner = new IetfLanguageTagCleaner("wee-Latn"); cleaner.Clean(); Assert.That(cleaner.GetCompleteTag(), Is.EqualTo("qaa-Latn-x-wee")); // Also when initially "Latn" is properly in the Script field. cleaner = new IetfLanguageTagCleaner("wee", "Latn", "", "", ""); cleaner.Clean(); Assert.That(cleaner.GetCompleteTag(), Is.EqualTo("qaa-Latn-x-wee")); }
///<summary> /// Constructor. ///</summary> ///<param name="idsInFile"></param> ///<param name="replaceIdsInFile"></param> ///<param name="writingSystemRepository"></param> public static void FindOrphans( IEnumerable<string> idsInFile, IdReplacementStrategy replaceIdsInFile, IWritingSystemRepository writingSystemRepository) { List<string> originalIds = idsInFile.ToList(); List<string> updatedIds = originalIds.ToList(); foreach (string wsId in originalIds) { // Check if it's in the repo if (writingSystemRepository.Contains(wsId)) { continue; } string newId; if (writingSystemRepository.WritingSystemIdHasChanged(wsId)) { newId = writingSystemRepository.WritingSystemIdHasChangedTo(wsId); } else { // It's an orphan // Clean it var rfcTagCleaner = new IetfLanguageTagCleaner(wsId); rfcTagCleaner.Clean(); newId = rfcTagCleaner.GetCompleteTag(); } WritingSystemDefinition conformantWritingSystem; writingSystemRepository.WritingSystemFactory.Create(newId, out conformantWritingSystem); // If it changed, then change if (conformantWritingSystem.LanguageTag != wsId) { conformantWritingSystem.LanguageTag = IetfLanguageTag.ToUniqueLanguageTag( conformantWritingSystem.LanguageTag, updatedIds); replaceIdsInFile(wsId, conformantWritingSystem.LanguageTag); updatedIds.Remove(wsId); updatedIds.Add(conformantWritingSystem.LanguageTag); } // Check if it's in the repo if (writingSystemRepository.Contains(conformantWritingSystem.LanguageTag)) continue; // It's not in the repo so set it writingSystemRepository.Set(conformantWritingSystem); } writingSystemRepository.Save(); }
public void CompleteTagConstructor_PrivateUseWithAudioAndDuplicateX_MakesAudioTag() { var cleaner = new IetfLanguageTagCleaner("x-en-Zxxx-x-audio"); cleaner.Clean(); Assert.That(cleaner.GetCompleteTag(), Is.EqualTo("qaa-Zxxx-x-en-Zxxx-audio")); }
public void CompleteTagConstructor_HasInvalidLanguageName_MovedToPrivateUse() { var cleaner = new IetfLanguageTagCleaner("234"); cleaner.Clean(); Assert.That(cleaner.GetCompleteTag(), Is.EqualTo("qaa-x-234")); }
public void CompleteTagConstructor_TagContainsOnlyPrivateUseWithAdditionalXDash_RedundantXDashRemoved() { var cleaner = new IetfLanguageTagCleaner("x-some-x-whatever"); cleaner.Clean(); Assert.That(cleaner.GetCompleteTag(), Is.EqualTo("qaa-x-some-whatever")); }
public void Language_XDashBeforeString_AddsQaa() { var cleaner = new IetfLanguageTagCleaner("x-blah"); cleaner.Clean(); Assert.That(cleaner.GetCompleteTag(), Is.EqualTo("qaa-x-blah")); }
public void CompleteTagConstructor_XDashBeforeValidLanguageNameInVariant_NoChange() { var cleaner = new IetfLanguageTagCleaner("", "", "", "x-de", ""); cleaner.Clean(); Assert.That(cleaner.GetCompleteTag(), Is.EqualTo("x-de")); }
void VerifyRfcCleaner(IetfLanguageTagCleaner cleaner, string language, string script, string region, string variant, string completeTag) { Assert.That(cleaner.Language, Is.EqualTo(language)); Assert.That(cleaner.Script, Is.EqualTo(script)); Assert.That(cleaner.Region, Is.EqualTo(region)); Assert.That(cleaner.Variant, Is.EqualTo(variant)); Assert.That(cleaner.GetCompleteTag(), Is.EqualTo(completeTag)); }
public void CompleteTagConstructor_LanguageNameWithAudio_GetZxxxAdded() { var cleaner = new IetfLanguageTagCleaner("aaa-x-audio"); cleaner.Clean(); Assert.That(cleaner.GetCompleteTag(), Is.EqualTo("aaa-Zxxx-x-audio")); }
public void CompleteTagConstructor_HasLanguageNameAndOtherName_OtherNameMovedToPrivateUse() { var cleaner = new IetfLanguageTagCleaner("abc-123"); cleaner.Clean(); Assert.That(cleaner.GetCompleteTag(), Is.EqualTo("abc-x-123")); }
public void CompleteTagConstructor_ValidRfctagWithLegacyIso3CodeAndPrivateUse_MigratesToRfc2LetterCodeAndPrivateUse() { var cleaner = new IetfLanguageTagCleaner("eng-bogus"); cleaner.Clean(); Assert.That(cleaner.GetCompleteTag(), Is.EqualTo("en-x-bogus")); }
public void CompleteTagConstructor_ValidRfctagWithPrivateUseElements_NoChange() { var cleaner = new IetfLanguageTagCleaner("qaa-Zxxx-x-Zxxx-AUDIO"); cleaner.Clean(); Assert.That(cleaner.GetCompleteTag(), Is.EqualTo("qaa-Zxxx-x-Zxxx-AUDIO")); // Except, it should have moved things from Language, where the constructor puts them, to the appropriate places. Assert.That(cleaner.Language, Is.EqualTo("qaa")); Assert.That(cleaner.Script, Is.EqualTo("Zxxx")); Assert.That(cleaner.PrivateUse, Is.EqualTo("Zxxx-AUDIO")); }