/// <summary> /// Determina a string exata de uma enum para comparação /// </summary> /// <param name="tipoEnum"></param> /// <returns></returns> private static string RetornarStringEnum(Type tipoEnum) { var enumInstance = new StringEnum(tipoEnum); var textoEnum = ""; foreach (var stringValue in enumInstance.GetStringValues()) { textoEnum += string.Format(@"""{0}"" | ", stringValue); } return textoEnum; }
public void TestInstancePropertyEnum() { StringEnum stringEnum = new StringEnum(typeof(EnumWithoutStrings)); Assert.IsTrue(stringEnum.EnumType.IsEnum); }
public void TestInstanceGetStringValues() { StringEnum stringEnum = new StringEnum(typeof(EnumWithoutStrings)); Assert.AreEqual(0, stringEnum.GetStringValues().Length); stringEnum = new StringEnum(typeof(EnumPartialStrings)); Assert.AreEqual(1, stringEnum.GetStringValues().Length); Assert.AreEqual("Jack be nimble", stringEnum.GetStringValues().GetValue(0).ToString()); }
public void TestInstanceIsStringDefined() { StringEnum stringEnum = new StringEnum(typeof(EnumWithStrings)); Assert.IsFalse(stringEnum.IsStringDefined("Something that's not there")); Assert.IsFalse(stringEnum.IsStringDefined("first value")); Assert.IsTrue(stringEnum.IsStringDefined("First Value")); }
public void TestInstanceGetStringValue() { StringEnum stringEnum = new StringEnum(typeof(EnumWithStrings)); Assert.AreEqual("Fourth Value", stringEnum.GetStringValue("Lazy")); //Expect null as this value doesn't exist Assert.IsNull(stringEnum.GetStringValue("clearly not there")); }