Esempio n. 1
0
        public void OrderOfDoubleAndDiacriticsDoesMatterButCanRemoveInEitherOrder()
        {
            var original = "Original String";

            // Apply both changes
            var doubleFirst = DoubleCommand.DoubleLogic(original, ToggleMode.Apply);

            doubleFirst = DiacriticsCommand.DiacriticsLogic(doubleFirst, ToggleMode.Apply);

            var diacriticsFirst = DiacriticsCommand.DiacriticsLogic(original, ToggleMode.Apply);

            diacriticsFirst = DoubleCommand.DoubleLogic(diacriticsFirst, ToggleMode.Apply);

            // Remove doubling first
            var doubleFirstRemoved = DoubleCommand.DoubleLogic(doubleFirst, ToggleMode.Reverse);

            doubleFirstRemoved = DiacriticsCommand.DiacriticsLogic(doubleFirstRemoved, ToggleMode.Reverse);

            var diacriticsFirstRemoved = DoubleCommand.DoubleLogic(diacriticsFirst, ToggleMode.Reverse);

            diacriticsFirstRemoved = DiacriticsCommand.DiacriticsLogic(diacriticsFirstRemoved, ToggleMode.Reverse);

            Assert.AreEqual(original, doubleFirstRemoved);
            Assert.AreEqual(original, diacriticsFirstRemoved);

            // Remove diacritics first
            doubleFirstRemoved = DiacriticsCommand.DiacriticsLogic(doubleFirst, ToggleMode.Reverse);
            doubleFirstRemoved = DoubleCommand.DoubleLogic(doubleFirstRemoved, ToggleMode.Reverse);

            diacriticsFirstRemoved = DiacriticsCommand.DiacriticsLogic(diacriticsFirst, ToggleMode.Reverse);
            diacriticsFirstRemoved = DoubleCommand.DoubleLogic(diacriticsFirstRemoved, ToggleMode.Reverse);

            Assert.AreEqual(original, doubleFirstRemoved);
            Assert.AreEqual(original, diacriticsFirstRemoved);
        }
        public static string Apply(string input, string command)
        {
            switch (command)
            {
            case nameof(DiacriticsCommand):
                return(DiacriticsCommand.DiacriticsLogic(input, ToggleMode.Apply));

            case nameof(DoubleCommand):
                return(DoubleCommand.DoubleLogic(input, ToggleMode.Apply));

            case nameof(InvertCaseCommand):
                return(InvertCaseCommand.InvertCaseLogic(input));

            case nameof(PaddingCommand):
                return(PaddingCommand.PaddingLogic(input, ToggleMode.Apply));

            case nameof(ReverseCommand):
                return(ReverseCommand.ReverseLogic(input));

            case nameof(SurroundCommand):
                return(SurroundCommand.SurroundLogic(input, ToggleMode.Apply));

            default:
                return(input);
            }
        }
Esempio n. 3
0
        public void RemoveDoubleWhenAlsoHasDiacritics_ButFirstCharIsNotALetter()
        {
            var actual = DoubleCommand.DoubleLogic(
                ">a\u0306\u032Ea\u0306\u032Eb\u0306\u032Eb\u0306\u032Ec\u0306\u032Ec\u0306\u032Ed\u0306\u032Ed\u0306\u032Ee\u0306\u032Ee\u0306\u032E",
                ToggleMode.Reverse);

            Assert.AreEqual(">a\u0306\u032Eb\u0306\u032Ec\u0306\u032Ed\u0306\u032Ee\u0306\u032E", actual);
        }
Esempio n. 4
0
        public void RemovePaddingWhenHasAlsoBeenDoubled()
        {
            var origin = "ab";

            var actual = PaddingCommand.PaddingLogic(origin, ToggleMode.Apply);

            actual = DoubleCommand.DoubleLogic(actual, ToggleMode.Apply);
            actual = PaddingCommand.PaddingLogic(actual, ToggleMode.Reverse);

            Assert.AreEqual("aabb", actual);
        }
Esempio n. 5
0
        public void CallingApplyMultipleTimesHasNoEffect()
        {
            var origin = "Original String";

            var once = DoubleCommand.DoubleLogic(origin, ToggleMode.Apply);

            var twice = DoubleCommand.DoubleLogic(origin, ToggleMode.Apply);

            twice = DoubleCommand.DoubleLogic(twice, ToggleMode.Apply);

            Assert.AreEqual(once, twice);
        }
Esempio n. 6
0
        public void OrderOfDoubleAndDiacriticsDoesMatter()
        {
            var original = "Original String";

            var doubleFirst = DoubleCommand.DoubleLogic(original, ToggleMode.Apply);

            doubleFirst = DiacriticsCommand.DiacriticsLogic(doubleFirst, ToggleMode.Apply);

            var diacriticsFirst = DiacriticsCommand.DiacriticsLogic(original, ToggleMode.Apply);

            diacriticsFirst = DoubleCommand.DoubleLogic(diacriticsFirst, ToggleMode.Apply);

            // This is because the diacritic used is based on the string length
            Assert.AreNotEqual(doubleFirst, diacriticsFirst);
        }
Esempio n. 7
0
        public void CanAddAndRemoveToggleActionsInDifferentOrder()
        {
            var origin = "Original String";

            var modifiedStep1  = SurroundCommand.SurroundLogic(origin, ToggleMode.Apply);
            var modifiedStep2  = DiacriticsCommand.DiacriticsLogic(modifiedStep1, ToggleMode.Apply);
            var modifiedStep3  = DoubleCommand.DoubleLogic(modifiedStep2, ToggleMode.Apply);
            var modifiedStep4  = ReverseCommand.ReverseLogic(modifiedStep3);
            var modifiedStep5  = PaddingCommand.PaddingLogic(modifiedStep4, ToggleMode.Apply);
            var modifiedStep6  = InvertCaseCommand.InvertCaseLogic(modifiedStep5);
            var modifiedStep7  = DiacriticsCommand.DiacriticsLogic(modifiedStep6, ToggleMode.Reverse);
            var modifiedStep8  = SurroundCommand.SurroundLogic(modifiedStep7, ToggleMode.Reverse);
            var modifiedStep9  = DoubleCommand.DoubleLogic(modifiedStep8, ToggleMode.Reverse);
            var modifiedStep10 = ReverseCommand.ReverseLogic(modifiedStep9);
            var modifiedStep11 = InvertCaseCommand.InvertCaseLogic(modifiedStep10);
            var finalResult    = PaddingCommand.PaddingLogic(modifiedStep11, ToggleMode.Reverse);

            Assert.AreEqual(origin, finalResult);
        }
Esempio n. 8
0
        public void HandlesEmptyString_Reverse()
        {
            var actual = DoubleCommand.DoubleLogic(string.Empty, ToggleMode.Reverse);

            Assert.AreEqual(string.Empty, actual);
        }
Esempio n. 9
0
        public void SpacesAtStartAndEndAreIgnoredWhenRemovingDoubles()
        {
            var actual = DoubleCommand.DoubleLogic(" AA cc ", ToggleMode.Reverse);

            Assert.AreEqual(" A c ", actual);
        }
Esempio n. 10
0
        public void SpacesAreNotDoubled()
        {
            var actual = DoubleCommand.DoubleLogic("A c", ToggleMode.Apply);

            Assert.AreEqual("AA cc", actual);
        }
Esempio n. 11
0
        public void PartialDoublesAreDoubled()
        {
            var actual = DoubleCommand.DoubleLogic("AAbc", ToggleMode.Apply);

            Assert.AreEqual("AAAAbbcc", actual);
        }
Esempio n. 12
0
        public void RemoveDoubles()
        {
            var actual = DoubleCommand.DoubleLogic("aabbcc", ToggleMode.Reverse);

            Assert.AreEqual("abc", actual);
        }
Esempio n. 13
0
        public void MakeDouble()
        {
            var actual = DoubleCommand.DoubleLogic("abc", ToggleMode.Apply);

            Assert.AreEqual("aabbcc", actual);
        }
Esempio n. 14
0
        public void DoubleWhenAlreadyHasDiacritics()
        {
            var actual = DoubleCommand.DoubleLogic("a\u0302\u032Db\u0302\u032Dc\u0302\u032Dd\u0302\u032De\u0302\u032D", ToggleMode.Apply);

            Assert.AreEqual("a\u0302\u032Da\u0302\u032Db\u0302\u032Db\u0302\u032Dc\u0302\u032Dc\u0302\u032Dd\u0302\u032Dd\u0302\u032De\u0302\u032De\u0302\u032D", actual);
        }
Esempio n. 15
0
        public void RemoveDoublingWhenHasAlsoBeenPadded()
        {
            var actual = DoubleCommand.DoubleLogic("a-a-b-b", ToggleMode.Reverse);

            Assert.AreEqual("a-b", actual);
        }
Esempio n. 16
0
        public void CanHandleNonAscii()
        {
            var actual = DoubleCommand.DoubleLogic("mrläcey", ToggleMode.Apply);

            Assert.AreEqual("mmrrllääcceeyy", actual);
        }
Esempio n. 17
0
        public void DoubleWhenAlreadyPadded()
        {
            var actual = DoubleCommand.DoubleLogic("d-o-u-b-l-e m-e", ToggleMode.Apply);

            Assert.AreEqual("d-d-o-o-u-u-b-b-l-l-e-e m-m-e-e", actual);
        }
Esempio n. 18
0
        public void DoubleWhenAlreadySurrounded()
        {
            var actual = DoubleCommand.DoubleLogic("[! double me !]", ToggleMode.Apply);

            Assert.AreEqual("[! ddoouubbllee mmee !]", actual);
        }
Esempio n. 19
0
        public void CanHandleCyrillic()
        {
            var actual = DoubleCommand.DoubleLogic("матт", ToggleMode.Apply);

            Assert.AreEqual("ммаатттт", actual);
        }
Esempio n. 20
0
        public void NonLettersArentDoubled()
        {
            var actual = DoubleCommand.DoubleLogic("1234$%^&", ToggleMode.Apply);

            Assert.AreEqual("1234$%^&", actual);
        }