예제 #1
0
 public void TestValidate()
 {
     StringEnumRule test = new StringEnumRule(new string[] { "a", "b" });
     Assert.True(test.Validate("a", null));
     Assert.True(test.Validate("b", null));
     Assert.False(test.Validate("c", null));
 }
예제 #2
0
 /// <summary>
 /// Set up any enumerations whose values are stored as strings
 /// </summary>
 /// <param name="attribute"></param>
 /// <param name="enumType"></param>
 public static void SetupStringBasedEnumeration(AttributeInfo attribute, Type enumType)
 {
     var strings = Enum.GetNames(enumType);
     AttributeRule rule = new StringEnumRule(strings);
     attribute.AddRule(rule);
     attribute.DefaultValue = strings[0];
 }