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);
            }
        }
Exemple #2
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);
        }
Exemple #3
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);
        }
Exemple #4
0
        /// <summary>
        /// Initialization of the package; this method is called right after the package is sited, so this is the place
        /// where you can put all the initialization code that rely on services provided by VisualStudio.
        /// </summary>
        /// <param name="cancellationToken">A cancellation token to monitor for initialization cancellation, which can occur when VS is shutting down.</param>
        /// <param name="progress">A provider for progress updates.</param>
        /// <returns>A task representing the async work of package initialization, or an already completed task if there is none. Do not return null from this method.</returns>
        protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress)
        {
            // When initialized asynchronously, the current thread may be a background thread at this point.
            // Do any initialization that requires the UI thread after switching to the UI thread.
            await this.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);

            await SurroundCommand.InitializeAsync(this);

            await ReverseCommand.InitializeAsync(this);

            await PaddingCommand.InitializeAsync(this);

            await InvertCaseCommand.InitializeAsync(this);

            await DiacriticsCommand.InitializeAsync(this);

            await DoubleCommand.InitializeAsync(this);

            await UppercaseCommand.InitializeAsync(this);

            await XxxxxCommand.InitializeAsync(this);

            await L337Command.InitializeAsync(this);

            await AlternateCaseCommand.InitializeAsync(this);

            await SponsorRequestHelper.CheckIfNeedToShowAsync();
        }
Exemple #5
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);
        }
Exemple #6
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);
        }
Exemple #7
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);
        }
Exemple #8
0
        public void Padding_RemovesWhereHave()
        {
            var origin = new List <string> {
                "P-a-d-d-e-d", "not padded", "A-l-s-o p-a-d-d-e-d"
            };

            var sut = PaddingCommand.CreateForTesting();

            var actual = sut.TestActingOnMultipleStrings(origin);

            var expected = new List <string> {
                "Padded", "not padded", "Also padded"
            };

            Assert.That.StringListsAreEqual(expected, actual);
        }
Exemple #9
0
        public void Padding_WithSurround_AddsWhereDoNotHave()
        {
            var origin = new List <string> {
                "[! not padded !]", "[! P-a-d-d-e-d !]", "[! also not padded !]"
            };

            var sut = PaddingCommand.CreateForTesting();

            var actual = sut.TestActingOnMultipleStrings(origin);

            var expected = new List <string> {
                "[! n-o-t p-a-d-d-e-d !]", "[! P-a-d-d-e-d !]", "[! a-l-s-o n-o-t p-a-d-d-e-d !]"
            };

            Assert.That.StringListsAreEqual(expected, actual);
        }
Exemple #10
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);
        }
Exemple #11
0
        public void AddPadding_TwoCharString_alpha()
        {
            var actual = PaddingCommand.AddPadding("AB");

            Assert.AreEqual("A-B", actual);
        }
Exemple #12
0
        public void AddPadding_TwoCharString_numeric()
        {
            var actual = PaddingCommand.AddPadding("12");

            Assert.AreEqual("12", actual);
        }
Exemple #13
0
        public void AddPadding_OneCharString()
        {
            var actual = PaddingCommand.AddPadding("1");

            Assert.AreEqual("1", actual);
        }
Exemple #14
0
        public void AddPadding_WhiteSpace()
        {
            var actual = PaddingCommand.AddPadding(" ");

            Assert.AreEqual(" ", actual);
        }
Exemple #15
0
        public void CanUnPadCyrillic()
        {
            var actual = PaddingCommand.PaddingLogic("м-а-т-т", ToggleMode.Reverse);

            Assert.AreEqual("матт", actual);
        }
Exemple #16
0
        public void ThreeLetters()
        {
            var actual = PaddingCommand.PaddingLogic("abc", ToggleMode.Apply);

            Assert.AreEqual("a-b-c", actual);
        }
Exemple #17
0
        public void TwoMixedCaseLetters()
        {
            var actual = PaddingCommand.PaddingLogic("Ab", ToggleMode.Apply);

            Assert.AreEqual("A-b", actual);
        }
Exemple #18
0
        public void IsPadded_IsFalse_Null()
        {
            var actual = PaddingCommand.IsPadded(null);

            Assert.IsFalse(actual);
        }
Exemple #19
0
        public void SingleChar_Apply()
        {
            var actual = PaddingCommand.PaddingLogic("a", ToggleMode.Apply);

            Assert.AreEqual("a", actual);
        }
Exemple #20
0
        public void IsPadded_IsFalse_OneCharString()
        {
            var actual = PaddingCommand.IsPadded("1");

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

            Assert.AreEqual("a\u0304\u0308b\u0304\u0308", actual);
        }
Exemple #22
0
        public void CanUnPadNonAscii()
        {
            var actual = PaddingCommand.PaddingLogic("ä-ä-ä", ToggleMode.Reverse);

            Assert.AreEqual("äää", actual);
        }
Exemple #23
0
        public void AddPadding_ThreeCharString()
        {
            var actual = PaddingCommand.AddPadding("123");

            Assert.AreEqual("1-2-3", actual);
        }
Exemple #24
0
        public void CanCallRemovePaddingForShortUnpaddedStrings()
        {
            var actual = PaddingCommand.RemovePadding("12");

            Assert.AreEqual("12", actual);
        }
Exemple #25
0
        public void SingleChar_Reverse()
        {
            var actual = PaddingCommand.PaddingLogic("a", ToggleMode.Reverse);

            Assert.AreEqual("a", actual);
        }
Exemple #26
0
        public void AddPadding_Null()
        {
            var actual = PaddingCommand.AddPadding(null);

            Assert.AreEqual(null, actual);
        }
Exemple #27
0
        public void TwoSeparatedMixedCaseLetters()
        {
            var actual = PaddingCommand.PaddingLogic("a-B", ToggleMode.Reverse);

            Assert.AreEqual("aB", actual);
        }
Exemple #28
0
        public void AddPadding_EmptyString()
        {
            var actual = PaddingCommand.AddPadding(string.Empty);

            Assert.AreEqual(string.Empty, actual);
        }
Exemple #29
0
        public void IsPadded_IsFalse_EmptyString()
        {
            var actual = PaddingCommand.IsPadded(string.Empty);

            Assert.IsFalse(actual);
        }
Exemple #30
0
        public void EmptyString_Reverse()
        {
            var actual = PaddingCommand.PaddingLogic(string.Empty, ToggleMode.Reverse);

            Assert.AreEqual(string.Empty, actual);
        }