public static void Enum_Succeeds_ForAliasValue(string value) { var result = ParseTo.Enum <My.Enum012>(value); Assert.True(result.HasValue); Assert.Equal(My.Enum012.Alias1, result.Value); }
public static void Enum_Succeeds_ForCompositeValue_BitFlagsEnum(string value) { var result = ParseTo.Enum <My.EnumBits>(value); Assert.True(result.HasValue); Assert.Equal(My.EnumBits.OneTwo, result.Value); }
// Weird but passing any integer value will succeed. public static void Enum_Succeeds_ForInvalidIntegerInput(string value) { var result = ParseTo.Enum <My.Enum012>(value); Assert.True(result.HasValue); Assert.Equal((My.Enum012) 4, result.Value); }
public static void Enum_ReturnsNull_ForCompositeValue_BitFlagsEnum_DoNotIgnoreCase(string value) { var result = ParseTo.Enum <My.EnumBits>(value, ignoreCase: false); Assert.False(result.HasValue); }
public static void Enum_ReturnsNull_ForAliasValue_DoNotIgnoreCase(string value) { var result = ParseTo.Enum <My.Enum012>(value, ignoreCase: false); Assert.False(result.HasValue); }
public static void Enum_ReturnsNull_ForInvalidValue(string value) { var result = ParseTo.Enum <My.Enum012>(value); Assert.False(result.HasValue); }
public static void Enum_ThrowsArgumentException_ForNonEnumerationStruct() => Assert.Throws <ArgumentException>(() => ParseTo.Enum <My.EmptyVal>("Whatever"));
public static void Enum_ThrowsArgumentException_ForInt32() => Assert.Throws <ArgumentException>(() => ParseTo.Enum <int>("Whatever"));