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. 2
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();
        }
Esempio n. 3
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);
        }
Esempio n. 4
0
        public void CallingApplyMultipleTimesHasNoEffect()
        {
            var origin = "Original String";

            var once = SurroundCommand.SurroundLogic(origin, ToggleMode.Apply);

            var twice = SurroundCommand.SurroundLogic(origin, ToggleMode.Apply);

            twice = SurroundCommand.SurroundLogic(twice, ToggleMode.Apply);

            Assert.AreEqual(once, twice);
        }
Esempio n. 5
0
        public void Surrounded_AddsWhereDoNotHave()
        {
            var origin = new List <string> {
                "not surrounded", "[! surrounded !]", "also not surrounded"
            };

            var sut = SurroundCommand.CreateForTesting();

            var actual = sut.TestActingOnMultipleStrings(origin);

            var expected = new List <string> {
                "[! not surrounded !]", "[! surrounded !]", "[! also not surrounded !]"
            };

            Assert.That.StringListsAreEqual(expected, actual);
        }
Esempio n. 6
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. 7
0
        public void CanHandleNull()
        {
            var actual = SurroundCommand.SurroundLogic(null, ToggleMode.Apply);

            Assert.AreEqual(null, actual);
        }
Esempio n. 8
0
        public void DoNotAddIfThere()
        {
            var actual = SurroundCommand.SurroundLogic("[! abc !]", ToggleMode.Apply);

            Assert.AreEqual("[! abc !]", actual);
        }
Esempio n. 9
0
        public void AlreadyHasAtEnd()
        {
            var actual = SurroundCommand.SurroundLogic("abc !]", ToggleMode.Apply);

            Assert.AreEqual("[! abc !] !]", actual);
        }
Esempio n. 10
0
        public void DoNotRemoveIfNotThere()
        {
            var actual = SurroundCommand.SurroundLogic("abc", ToggleMode.Reverse);

            Assert.AreEqual("abc", actual);
        }
Esempio n. 11
0
        public void HasBoth()
        {
            var actual = SurroundCommand.SurroundLogic("[! abc !]", ToggleMode.Reverse);

            Assert.AreEqual("abc", actual);
        }
Esempio n. 12
0
        public void HasNone()
        {
            var actual = SurroundCommand.SurroundLogic("abc", ToggleMode.Apply);

            Assert.AreEqual("[! abc !]", actual);
        }
Esempio n. 13
0
        public void CanHandleToggleModeNotSet()
        {
            var actual = SurroundCommand.SurroundLogic("Something", ToggleMode.NotSet);

            Assert.AreEqual("Something", actual);
        }
Esempio n. 14
0
        public void CanHandleWhiteSpace()
        {
            var actual = SurroundCommand.SurroundLogic(" ", ToggleMode.Apply);

            Assert.AreEqual(" ", actual);
        }
Esempio n. 15
0
        public void CanHandleEmptyString()
        {
            var actual = SurroundCommand.SurroundLogic(string.Empty, ToggleMode.Apply);

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