public void Test_VstCanDoHelper_PluginCanDo_ToString() { VstPluginCanDo cando = VstPluginCanDo.Bypass; string actual = VstCanDoHelper.ToString(cando); Assert.AreEqual("bypass", actual, "PluginCanDo.Bypass failed."); cando = VstPluginCanDo.x1in1out; actual = VstCanDoHelper.ToString(cando); Assert.AreEqual("1in1out", actual, "PluginCanDo.x1in1out failed."); }
public void Test_VstCanDoHelper_ParsePluginCanDo() { string cando = "1in1out"; VstPluginCanDo actual = VstCanDoHelper.ParsePluginCanDo(cando); Assert.AreEqual(VstPluginCanDo.x1in1out, actual, "PluginCanDo.x1in1out failed."); cando = "bypass"; actual = VstCanDoHelper.ParsePluginCanDo(cando); Assert.AreEqual(VstPluginCanDo.Bypass, actual, "PluginCanDo.Bypass failed."); }
public void Test_VstCanDoHelper_PluginCanDo_ToString() { VstPluginCanDo cando = VstPluginCanDo.Bypass; var actual = VstCanDoHelper.ToString(cando); actual.Should().Be("bypass"); cando = VstPluginCanDo.x1in1out; actual = VstCanDoHelper.ToString(cando); actual.Should().Be("1in1out"); }
/// <summary> /// Converts a <paramref name="cando"/> value to a string compatible with VST. /// </summary> /// <param name="cando">The value to convert to string.</param> /// <returns>Returns the string value for the <paramref name="cando"/>.</returns> public static string ToString(VstPluginCanDo cando) { string result = cando.ToString(); if (result[0] == _digitEscapeChar) { // strip of leading digit escape char result = result.Substring(1); } else { // lower case on first character result = char.ToLowerInvariant(result[0]) + result.Substring(1); } return(result); }
/// <summary> /// Attempts to parse the <paramref name="cando"/> string. /// </summary> /// <param name="cando">Must not be null or empty.</param> /// <returns>Returns <see cref="VstPluginCanDo.Unknown"/> when string did not match an enum value.</returns> /// <exception cref="ArgumentNullException">Thrown when <paramref name="cando"/> is not set to an instance of an object.</exception> /// <exception cref="ArgumentException">Thrown when <paramref name="cando"/> is an empty string.</exception> public static VstPluginCanDo ParsePluginCanDo(string cando) { Throw.IfArgumentIsNullOrEmpty(cando, "cando"); VstPluginCanDo result = VstPluginCanDo.Unknown; Type enumType = typeof(VstPluginCanDo); if (Char.IsDigit(cando[0])) { cando = _digitEscapeChar + cando; } foreach (string name in Enum.GetNames(enumType)) { if (name.Equals(cando, StringComparison.InvariantCultureIgnoreCase)) { result = (VstPluginCanDo)Enum.Parse(enumType, cando, true); break; } } return(result); }