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); } }
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); }
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 = DoubleCommand.DoubleLogic(origin, ToggleMode.Apply); var twice = DoubleCommand.DoubleLogic(origin, ToggleMode.Apply); twice = DoubleCommand.DoubleLogic(twice, ToggleMode.Apply); Assert.AreEqual(once, twice); }
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); }
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 HandlesEmptyString_Reverse() { var actual = DoubleCommand.DoubleLogic(string.Empty, ToggleMode.Reverse); Assert.AreEqual(string.Empty, actual); }
public void SpacesAtStartAndEndAreIgnoredWhenRemovingDoubles() { var actual = DoubleCommand.DoubleLogic(" AA cc ", ToggleMode.Reverse); Assert.AreEqual(" A c ", actual); }
public void SpacesAreNotDoubled() { var actual = DoubleCommand.DoubleLogic("A c", ToggleMode.Apply); Assert.AreEqual("AA cc", actual); }
public void PartialDoublesAreDoubled() { var actual = DoubleCommand.DoubleLogic("AAbc", ToggleMode.Apply); Assert.AreEqual("AAAAbbcc", actual); }
public void RemoveDoubles() { var actual = DoubleCommand.DoubleLogic("aabbcc", ToggleMode.Reverse); Assert.AreEqual("abc", actual); }
public void MakeDouble() { var actual = DoubleCommand.DoubleLogic("abc", ToggleMode.Apply); Assert.AreEqual("aabbcc", actual); }
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); }
public void RemoveDoublingWhenHasAlsoBeenPadded() { var actual = DoubleCommand.DoubleLogic("a-a-b-b", ToggleMode.Reverse); Assert.AreEqual("a-b", actual); }
public void CanHandleNonAscii() { var actual = DoubleCommand.DoubleLogic("mrläcey", ToggleMode.Apply); Assert.AreEqual("mmrrllääcceeyy", actual); }
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); }
public void DoubleWhenAlreadySurrounded() { var actual = DoubleCommand.DoubleLogic("[! double me !]", ToggleMode.Apply); Assert.AreEqual("[! ddoouubbllee mmee !]", actual); }
public void CanHandleCyrillic() { var actual = DoubleCommand.DoubleLogic("матт", ToggleMode.Apply); Assert.AreEqual("ммаатттт", actual); }
public void NonLettersArentDoubled() { var actual = DoubleCommand.DoubleLogic("1234$%^&", ToggleMode.Apply); Assert.AreEqual("1234$%^&", actual); }