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);
            }
        }
Example #2
0
        public void CanPadTextWithCombiningCharacters()
        {
            // 304=macron 308=umlaut
            var actual = PaddingCommand.PaddingLogic("a\u0304\u0308b\u0304\u0308", ToggleMode.Apply);

            Assert.AreEqual("a\u0304\u0308-b\u0304\u0308", actual);
        }
Example #3
0
        public void AlreadyHasDoubleSpacedLetters()
        {
            // Double separators are on the limit of scope. Happy to remove both
            var actual = PaddingCommand.PaddingLogic("a--b", ToggleMode.Reverse);

            Assert.AreEqual("ab", actual);
        }
Example #4
0
        public void AddPadding_WhereAlreadyHasSurrounds()
        {
            var origin = "Original String";

            var withSurrounds = SurroundCommand.SurroundLogic(origin, ToggleMode.Apply);
            var withPadding   = PaddingCommand.PaddingLogic(withSurrounds, ToggleMode.Apply);

            Assert.AreEqual("[! O-r-i-g-i-n-a-l S-t-r-i-n-g !]", withPadding);
        }
Example #5
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);
        }
Example #6
0
        public void CallingApplyMultipleTimesHasNoEffect()
        {
            var origin = "Original String";

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

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

            twice = PaddingCommand.PaddingLogic(twice, ToggleMode.Apply);

            Assert.AreEqual(once, twice);
        }
Example #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);
        }
Example #8
0
        public void TwoMixedCaseLetters()
        {
            var actual = PaddingCommand.PaddingLogic("Ab", ToggleMode.Apply);

            Assert.AreEqual("A-b", actual);
        }
Example #9
0
        public void SingleChar_Reverse()
        {
            var actual = PaddingCommand.PaddingLogic("a", ToggleMode.Reverse);

            Assert.AreEqual("a", actual);
        }
Example #10
0
        public void SingleChar_Apply()
        {
            var actual = PaddingCommand.PaddingLogic("a", ToggleMode.Apply);

            Assert.AreEqual("a", actual);
        }
Example #11
0
        public void CanUnPadTextWithCombiningCharacters()
        {
            var actual = PaddingCommand.PaddingLogic("a\u0304\u0308-b\u0304\u0308", ToggleMode.Reverse);

            Assert.AreEqual("a\u0304\u0308b\u0304\u0308", actual);
        }
Example #12
0
        public void CanUnPadCyrillic()
        {
            var actual = PaddingCommand.PaddingLogic("м-а-т-т", ToggleMode.Reverse);

            Assert.AreEqual("матт", actual);
        }
Example #13
0
        public void CanUnPadNonAscii()
        {
            var actual = PaddingCommand.PaddingLogic("ä-ä-ä", ToggleMode.Reverse);

            Assert.AreEqual("äää", actual);
        }
Example #14
0
        public void EmptyString_Reverse()
        {
            var actual = PaddingCommand.PaddingLogic(string.Empty, ToggleMode.Reverse);

            Assert.AreEqual(string.Empty, actual);
        }
Example #15
0
        public void TwoSeparatedMixedCaseLetters()
        {
            var actual = PaddingCommand.PaddingLogic("a-B", ToggleMode.Reverse);

            Assert.AreEqual("aB", actual);
        }
Example #16
0
        public void ThreeSeparatedLetters()
        {
            var actual = PaddingCommand.PaddingLogic("a-b-c", ToggleMode.Reverse);

            Assert.AreEqual("abc", actual);
        }
Example #17
0
        public void HasSeparatorNotNextToLetters_Reverse()
        {
            var actual = PaddingCommand.PaddingLogic("a - b", ToggleMode.Reverse);

            Assert.AreEqual("a - b", actual);
        }
Example #18
0
        public void HasSeparatorBeforeSingleLetter_Reverse()
        {
            var actual = PaddingCommand.PaddingLogic("-a", ToggleMode.Reverse);

            Assert.AreEqual("-a", actual);
        }
Example #19
0
        public void EmptyString_Apply()
        {
            var actual = PaddingCommand.PaddingLogic(string.Empty, ToggleMode.Apply);

            Assert.AreEqual(string.Empty, actual);
        }
Example #20
0
        public void HasSeparatorAfterSingleLetter_Apply()
        {
            var actual = PaddingCommand.PaddingLogic("a-", ToggleMode.Apply);

            Assert.AreEqual("a-", actual);
        }
Example #21
0
        public void TwoSpaceSeparatedLetters_Reverse()
        {
            var actual = PaddingCommand.PaddingLogic("a b", ToggleMode.Reverse);

            Assert.AreEqual("a b", actual);
        }
Example #22
0
        public void ThreeLetters()
        {
            var actual = PaddingCommand.PaddingLogic("abc", ToggleMode.Apply);

            Assert.AreEqual("a-b-c", actual);
        }
Example #23
0
        public void AlreadyHasHyphenatedWordInSentenceWithPadding()
        {
            var actual = PaddingCommand.PaddingLogic("C-o-n-t-a-i-n-s a h-y-p-h-e-n-a-t-e-d---w-o-r-d i-n i-n-p-u-t-.", ToggleMode.Reverse);

            Assert.AreEqual("Contains a hyphenated-word in input.", actual);
        }