public void NotZeroInt32_WithCustomException_CustomTypeException() { int value = 0; CustomException exc = Assert.Throws <CustomException>(() => Arg.Validate(value, nameof(value)) .With <CustomException>() .NotZero()); CustomAssert.MessageForNotZeroMethodIsValid(value, exc); }
public void ZeroFloat_WithCustomException_CustomTypeException() { float value = 1; CustomException exc = Assert.Throws <CustomException>(() => Arg.Validate(value, nameof(value)) .With <CustomException>() .Zero()); CustomAssert.MessageForZeroMethodIsValid(value, exc); }
public void NegativeOrZeroDouble_WithCustomException_CustomTypeException() { double value = 1; CustomException exc = Assert.Throws <CustomException>(() => Arg.Validate(value, nameof(value)) .With <CustomException>() .NegativeOrZero()); CustomAssert.MessageForNegativeOrZeroMethodIsValid(value, exc); }
public void NegativeDecimal_WithCustomException_CustomTypeException() { decimal value = 1; CustomException exc = Assert.Throws <CustomException>(() => Arg.Validate(value, nameof(value)) .With <CustomException>() .Negative()); CustomAssert.MessageForNegativeMethodIsValid(value, exc); }
public void PositiveOrZeroDecimal_WithCustomException_CustomTypeException() { decimal value = -1; CustomException exc = Assert.Throws <CustomException>(() => Arg.Validate(value, nameof(value)) .With <CustomException>() .PositiveOrZero()); CustomAssert.MessageForPositiveOrZeroMethodIsValid(value, exc); }
public void PositiveFloat_WithCustomException_CustomTypeException() { float value = -1; CustomException exc = Assert.Throws <CustomException>(() => Arg.Validate(value, nameof(value)) .With <CustomException>() .Positive()); CustomAssert.MessageForPositiveMethodIsValid(value, exc); }
public static void MessageForNotZeroMethodIsValid <T>(T value, CustomException exc) { Assert.Equal($"Argument 'value' must be not equal '{value}'", exc.Message); }
public static void MessageForNegativeOrZeroMethodIsValid <T>(T value, CustomException exc) { Assert.Equal($"The maximum value for the argument 'value' is '0'. Current value: '{value}'", exc.Message); }
public static void MessageForNegativeMethodIsValid <T>(T value, CustomException exc) { Assert.Equal($"Argument 'value' must be less than '0'. Current value: '{value}'", exc.Message); }