// 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 Boolean_ReturnsFalse_ForEmptyString_EmptyOrWhiteSpaceIsFalseStyle(string value) { var result = ParseTo.Boolean(value, BooleanStyles.EmptyOrWhiteSpaceIsFalse); Assert.True(result.HasValue); Assert.False(result.Value); }
public static void Boolean_ReturnsFalse_ForLiteralZero_ZeroOrOneStyle(string value) { var result = ParseTo.Boolean(value, BooleanStyles.ZeroOrOne); Assert.True(result.HasValue); Assert.False(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); }
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 Boolean_ReturnsTrue_ForLiteralTrue_LiteralStyle(string value) { var result = ParseTo.Boolean(value, BooleanStyles.Literal); Assert.True(result.HasValue); Assert.True(result.Value); }
public static void Boolean_ReturnsNull_ForInvalidInput_ZeroOrOneStyle(string value) { var result = ParseTo.Boolean(value, BooleanStyles.ZeroOrOne); Assert.False(result.HasValue); }
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 Boolean_ReturnsNull_ForNullString() { var result = ParseTo.Boolean(null); 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"));