Пример #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);
 }