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); } }
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); }
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); }
/// <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(); }
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); }
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); }
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); }
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); }
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); }
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); }
public void AddPadding_TwoCharString_alpha() { var actual = PaddingCommand.AddPadding("AB"); Assert.AreEqual("A-B", actual); }
public void AddPadding_TwoCharString_numeric() { var actual = PaddingCommand.AddPadding("12"); Assert.AreEqual("12", actual); }
public void AddPadding_OneCharString() { var actual = PaddingCommand.AddPadding("1"); Assert.AreEqual("1", actual); }
public void AddPadding_WhiteSpace() { var actual = PaddingCommand.AddPadding(" "); Assert.AreEqual(" ", actual); }
public void CanUnPadCyrillic() { var actual = PaddingCommand.PaddingLogic("м-а-т-т", ToggleMode.Reverse); Assert.AreEqual("матт", actual); }
public void ThreeLetters() { var actual = PaddingCommand.PaddingLogic("abc", ToggleMode.Apply); Assert.AreEqual("a-b-c", actual); }
public void TwoMixedCaseLetters() { var actual = PaddingCommand.PaddingLogic("Ab", ToggleMode.Apply); Assert.AreEqual("A-b", actual); }
public void IsPadded_IsFalse_Null() { var actual = PaddingCommand.IsPadded(null); Assert.IsFalse(actual); }
public void SingleChar_Apply() { var actual = PaddingCommand.PaddingLogic("a", ToggleMode.Apply); Assert.AreEqual("a", actual); }
public void IsPadded_IsFalse_OneCharString() { var actual = PaddingCommand.IsPadded("1"); Assert.IsFalse(actual); }
public void CanUnPadTextWithCombiningCharacters() { var actual = PaddingCommand.PaddingLogic("a\u0304\u0308-b\u0304\u0308", ToggleMode.Reverse); Assert.AreEqual("a\u0304\u0308b\u0304\u0308", actual); }
public void CanUnPadNonAscii() { var actual = PaddingCommand.PaddingLogic("ä-ä-ä", ToggleMode.Reverse); Assert.AreEqual("äää", actual); }
public void AddPadding_ThreeCharString() { var actual = PaddingCommand.AddPadding("123"); Assert.AreEqual("1-2-3", actual); }
public void CanCallRemovePaddingForShortUnpaddedStrings() { var actual = PaddingCommand.RemovePadding("12"); Assert.AreEqual("12", actual); }
public void SingleChar_Reverse() { var actual = PaddingCommand.PaddingLogic("a", ToggleMode.Reverse); Assert.AreEqual("a", actual); }
public void AddPadding_Null() { var actual = PaddingCommand.AddPadding(null); Assert.AreEqual(null, actual); }
public void TwoSeparatedMixedCaseLetters() { var actual = PaddingCommand.PaddingLogic("a-B", ToggleMode.Reverse); Assert.AreEqual("aB", actual); }
public void AddPadding_EmptyString() { var actual = PaddingCommand.AddPadding(string.Empty); Assert.AreEqual(string.Empty, actual); }
public void IsPadded_IsFalse_EmptyString() { var actual = PaddingCommand.IsPadded(string.Empty); Assert.IsFalse(actual); }
public void EmptyString_Reverse() { var actual = PaddingCommand.PaddingLogic(string.Empty, ToggleMode.Reverse); Assert.AreEqual(string.Empty, actual); }