Exemplo n.º 1
0
        public void AddToPrivateUse_PrivateUseIsEmpty_PrivateUseEqualsStringToAdd()
        {
            var rfcTag = new RFC5646Tag("en", String.Empty, String.Empty, String.Empty, String.Empty);

            rfcTag.AddToPrivateUse("audio");
            Assert.AreEqual("x-audio", rfcTag.PrivateUse);
        }
Exemplo n.º 2
0
        public void AddToPrivateUse_TagBeginningWithx_Set()
        {
            var rfcTag = new RFC5646Tag("en", String.Empty, String.Empty, String.Empty, String.Empty);

            rfcTag.AddToPrivateUse("xtest");
            Assert.AreEqual("x-xtest", rfcTag.PrivateUse);
        }
Exemplo n.º 3
0
        public void AddToPrivateUse_StringToAddEndsWithDash_StringIsAdded()
        {
            var rfcTag = new RFC5646Tag("en", String.Empty, String.Empty, String.Empty, "test");

            rfcTag.AddToPrivateUse("audio-");
            Assert.AreEqual("x-test-audio", rfcTag.PrivateUse);
        }
Exemplo n.º 4
0
        public void AddToPrivateUse_StringToAddConsistsOfMultipleParts_StringToAddIsAppendedToPrivateUseWithDashDelimiter()
        {
            var rfcTag = new RFC5646Tag("en", String.Empty, String.Empty, String.Empty, "test-audios");

            rfcTag.AddToPrivateUse("audio-variant2");
            Assert.AreEqual("x-test-audios-audio-variant2", rfcTag.PrivateUse);
        }
Exemplo n.º 5
0
        public void AddToPrivateUse_TagEndingInx_Set()
        {
            var rfcTag = new RFC5646Tag("en", String.Empty, String.Empty, String.Empty, String.Empty);

            rfcTag.AddToPrivateUse("testx");
            Assert.AreEqual("x-testx", rfcTag.PrivateUse);
        }
Exemplo n.º 6
0
        public void AddToPrivateUse_StringToAddIsSubStringOfStringAlreadyContainedInPrivateUse_StringToAddIsAppendedToPrivateUseWithDashDelimiter()
        {
            var rfcTag = new RFC5646Tag("en", String.Empty, String.Empty, String.Empty, "audios-test");

            rfcTag.AddToPrivateUse("audio");
            Assert.AreEqual("x-audios-test-audio", rfcTag.PrivateUse);
        }
Exemplo n.º 7
0
        public void AddToPrivateUse_PrivateUseIsNotEmpty_StringToAddIsAppendedToPrivateUseWithDashDelimiter()
        {
            var rfcTag = new RFC5646Tag("en", String.Empty, String.Empty, String.Empty, "test");

            rfcTag.AddToPrivateUse("audio");
            Assert.AreEqual("x-test-audio", rfcTag.PrivateUse);
        }
Exemplo n.º 8
0
        public void AddToPrivateUse_StringToAddWithx_Throws()
        {
            var rfcTag = new RFC5646Tag("en", String.Empty, String.Empty, String.Empty, "test");

            Assert.Throws <ValidationException>(
                () => rfcTag.AddToPrivateUse("bbb-x-audio")
                );
        }
        private static string UniqueTagForDuplicate(string rfcTag, IEnumerable <string> uniqueRfcTags)
        {
            RFC5646Tag tag = RFC5646Tag.Parse(rfcTag);
            string     originalPrivateUse = tag.PrivateUse;
            int        duplicateNumber    = 0;

            do
            {
                duplicateNumber++;
                tag.PrivateUse = originalPrivateUse;
                tag.AddToPrivateUse(String.Format("dupl{0}", duplicateNumber));
            } while (uniqueRfcTags.Any(s => s.Equals(tag.CompleteTag, StringComparison.OrdinalIgnoreCase)));
            return(tag.CompleteTag);
        }
Exemplo n.º 10
0
        public void AddToPrivateUse_StringToAddContainsUnderScoreAfterx_Throws()
        {
            var rfcTag = new RFC5646Tag("en", String.Empty, String.Empty, String.Empty, String.Empty);

            Assert.Throws <ValidationException>(() => rfcTag.AddToPrivateUse("x_audio"));
        }
Exemplo n.º 11
0
        public void AddToPrivateUse_StringToAddContainsNonAlphaNumericCharacter_Throws()
        {
            var rfcTag = new RFC5646Tag("en", String.Empty, String.Empty, String.Empty, String.Empty);

            Assert.Throws <ValidationException>(() => rfcTag.AddToPrivateUse("_audio"));
        }
Exemplo n.º 12
0
        public void AddToPrivateUse_PrivateUseAlreadyContainsStringToAddInDifferentCase_Throws()
        {
            var rfcTag = new RFC5646Tag("en", String.Empty, String.Empty, String.Empty, "AUDIO");

            Assert.Throws <ValidationException>(() => rfcTag.AddToPrivateUse("audio"));
        }
Exemplo n.º 13
0
        public void AddToPrivateUse_PrivateUseAlreadyContainsPartsOfStringToAdd_Throws()
        {
            var rfcTag = new RFC5646Tag("en", String.Empty, String.Empty, String.Empty, "audio-test");

            Assert.Throws <ValidationException>(() => rfcTag.AddToPrivateUse("smth-test"));
        }
Exemplo n.º 14
0
        public void AddToPrivateUse_StringToAddContainsIllegalCharacters_Throws()
        {
            var rfcTag = new RFC5646Tag("en", String.Empty, String.Empty, String.Empty, String.Empty);

            Assert.Throws <ValidationException>(() => rfcTag.AddToPrivateUse("x-audio_test"));
        }