public void Should_Not_DynamicallyReplaceAndColorize_IncorrectValue_Having_TwoReplacements() { string testString = "Not replace this incorrect key [incorrect key]"; string[] replacements = new[] { "Key_X", "Key_Y" }; string expected = "Not replace this incorrect key [incorrect key]"; string result = UIUtil.ColorizeDynamicKeybinds(testString, replacements); Assert.AreEqual(expected, result); }
public void Should_DynamicallyReplaceAndColorize_SingleValue_Having_OneReplacement() { string testString = "[[Page Down]] To switch underground view"; string[] replacements = new[] { "Key_X" }; string expected = $"{UConst.GetKeyboardShortcutColorTagOpener()}Key_X{UConst.KEYBOARD_SHORTCUT_CLOSING_TAG} To switch underground view"; string result = UIUtil.ColorizeDynamicKeybinds(testString, replacements); Assert.AreEqual(expected, result); }
/// <summary>Get a translation string and dynamically find, replace and paint [[Key]] fragments with orange.</summary> /// <param name="key">Translation key.</param> /// <returns>Translated and colorized string.</returns> public string ColorizeDynamicKeybinds(string key, string[] replacements) { string lang = Translation.GetCurrentLanguage(); return(UIUtil.ColorizeDynamicKeybinds(this.Get(lang, key), replacements)); }