예제 #1
0
        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);
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }
예제 #4
0
        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);
        }
예제 #5
0
        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);
        }
예제 #6
0
        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);
        }
예제 #7
0
 public static void MessageForNotZeroMethodIsValid <T>(T value, CustomException exc)
 {
     Assert.Equal($"Argument 'value' must be not equal '{value}'", exc.Message);
 }
예제 #8
0
 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);
 }
예제 #9
0
 public static void MessageForNegativeMethodIsValid <T>(T value, CustomException exc)
 {
     Assert.Equal($"Argument 'value' must be less than '0'. Current value: '{value}'", exc.Message);
 }