public void Method_List_CharactersAreAllReplaced_WhenUsingLoopFromPrevious() { var method = new CharacterSubstitutor(); method.Method = CharacterSubstitutor.SubstitutionMethod.List; method.ListMode = CharacterSubstitutor.ListSelectionMethod.LoopFromPrevious; method.ReplacementList.Clear(); method.ReplacementList.AddRange(new[] { 'A', 'B', 'C', 'D', 'E' }); const string input1 = "aaa"; const string input2 = "bbbb"; const string expected1 = "ABC"; const string expected2 = "DEAB"; var message1 = Message.CreateMessage(input1); var message2 = Message.CreateMessage(input2); method.Transform(message1); method.Transform(message2); Assert.AreEqual(expected1, message1.ToString(), "Expected the transformed string to match."); Assert.AreEqual(expected2, message2.ToString(), "Expected the transformed string to match."); message1.Release(); message2.Release(); }
public void Method_ToUpper_CharactersAreUppercase(string input, string expected) { var method = new CharacterSubstitutor(); method.Method = CharacterSubstitutor.SubstitutionMethod.ToUpper; var result = method.Transform(input); Assert.AreEqual(expected, result, "Expected the transformed string to match."); }
public void Method_ToLower_CharactersAreLowercase(string input, string expected) { var method = new CharacterSubstitutor(); method.Method = CharacterSubstitutor.SubstitutionMethod.ToLower; var message = Message.CreateMessage(input); method.Transform(message); Assert.AreEqual(expected, message.ToString(), "Expected the transformed string to match."); }
public void Method_List_CharactersAreAllReplaced_WhenUsingLoopFromStart(string input, string expected) { var method = new CharacterSubstitutor(); method.Method = CharacterSubstitutor.SubstitutionMethod.List; method.ListMode = CharacterSubstitutor.ListSelectionMethod.LoopFromStart; method.ReplacementList.Clear(); method.ReplacementList.AddRange(new[] { 'A', 'B', 'C' }); var result = method.Transform(input); Assert.AreEqual(expected, result, "Expected the transformed string to match."); }
public void Method_List_CharactersAreAllReplacedWhenUsingSingleReplacementChar(string input) { const char replacementChar = '_'; var method = new CharacterSubstitutor(); method.Method = CharacterSubstitutor.SubstitutionMethod.List; method.ReplacementList.Add(replacementChar); var result = method.Transform(input); var count = result.Count(o => o == replacementChar); Assert.AreEqual(input.Length, count, "Expected all characters to be replaced with the same character when replacement chars only has a single value: " + result); }
public void Method_Map_CharactersAreReplaced(string input, string expected) { var method = new CharacterSubstitutor(); method.Method = CharacterSubstitutor.SubstitutionMethod.Map; method.ReplacementMap['L'] = 'K'; method.ReplacementMap['R'] = 'A'; method.ReplacementMap['A'] = 'R'; method.ReplacementMap['K'] = 'L'; method.ReplacementMap['X'] = 'Y'; method.ReplacementMap['{'] = '['; method.ReplacementMap['}'] = ']'; var result = method.Transform(input); Assert.AreEqual(expected, result, "Expected the transformed string to match."); }
public void RichTextTagsArePreserved_WhenReplacingCharacters(string input, string expected) { // Replace each character with a wrapped number from 1-9 var replaceMethod = new CharacterSubstitutor(); replaceMethod.Method = CharacterSubstitutor.SubstitutionMethod.List; replaceMethod.ListMode = CharacterSubstitutor.ListSelectionMethod.LoopFromPrevious; replaceMethod.ReplacementList.Clear(); replaceMethod.ReplacementList.AddRange(Enumerable.Range(1, 9).Select(v => v.ToString()[0])); var message = Message.CreateMessage(input); m_Method.Transform(message); replaceMethod.Transform(message); Assert.AreEqual(expected, message.ToString()); message.Release(); }
public void Method_Map_CharactersAreReplaced(string input, string expected) { var method = new CharacterSubstitutor(); method.Method = CharacterSubstitutor.SubstitutionMethod.Map; method.ReplacementMap['L'] = 'K'; method.ReplacementMap['R'] = 'A'; method.ReplacementMap['A'] = 'R'; method.ReplacementMap['K'] = 'L'; method.ReplacementMap['X'] = 'Y'; method.ReplacementMap['{'] = '['; method.ReplacementMap['}'] = ']'; var message = Message.CreateMessage(input); method.Transform(message); Assert.AreEqual(expected, message.ToString(), "Expected the transformed string to match."); message.Release(); }