public void CountMoreThan_ValuesIsNull_ArgValidationException()
        {
            object[] nullValue         = null;
            ArgValidationException exc = Assert.Throws <ArgValidationException>(() => Arg.Validate(() => nullValue).CountMoreThan(0));

            Assert.Equal($"Argument '{nameof(nullValue)}' is null. Сan not get count elements from null object", exc.Message);
        }
Example #2
0
        public void Empty_ValuesIsNull_ArgValidationException()
        {
            object[] nullValue         = null;
            ArgValidationException exc = Assert.Throws <ArgValidationException>(() => RunEmpty(() => nullValue));

            Assert.Equal($"Argument '{nameof(nullValue)}' is null. Can not execute 'Empty' method", exc.Message);
        }
Example #3
0
        public void NotContains_ValuesIsNull_ArgValidationException()
        {
            object[] nullValue         = null;
            ArgValidationException exc = Assert.Throws <ArgValidationException>(() => Arg.Validate(() => nullValue).NotContains(new object()));

            Assert.Equal($"Argument '{nameof(nullValue)}' is null. Can not execute 'NotContains' method", exc.Message);
        }
Example #4
0
        public void NotMatch_ArgumentValueIsNull_ArgValidationException()
        {
            string                 nullValue = null;
            const string           pattern   = "\\d{10}";
            ArgValidationException exc       = Assert.Throws <ArgValidationException>(() => Arg.Validate(nullValue, nameof(nullValue)).NotMatch(pattern));

            Assert.Equal($"Argument '{nameof(nullValue)}' is null. Can not execute 'NotMatch' method", exc.Message);
        }
Example #5
0
        public void LengthEqual_ArgumentIsNull_ArgValidationException()
        {
            int    length              = 2;
            string nullString          = null;
            ArgValidationException exc = Assert.Throws <ArgValidationException>(() => Arg.Validate(() => nullString).LengthEqual(length));

            Assert.Equal($"Argument '{nameof(nullString)}' is null. Can not execute 'LengthEqual' method", exc.Message);
        }
        public void NotStartsWith_ValueIsNull_ArgValidationException()
        {
            ArgValidationException exc = Assert.Throws <ArgValidationException>(() =>
            {
                Arg.Validate(() => "value").NotStartsWith(null);
            });

            Assert.Equal("Argument 'value' of method 'NotStartsWith' is null. Can not execute 'NotStartsWith' method", exc.Message);
        }
Example #7
0
        public void NotMatch_Pattern_ArgValidationException()
        {
            string argValue            = "some-value";
            ArgValidationException exc = Assert.Throws <ArgValidationException>(() =>
                                                                                Arg.Validate(argValue, nameof(argValue))
                                                                                .NotMatch(pattern: null));

            Assert.Equal("Argument 'pattern' of method 'NotMatch' is null. Can not execute 'NotMatch' method", exc.Message);
        }
Example #8
0
        public void Contains_ArgumentIsNull_ArgValidationException()
        {
            string nullValue           = null;
            ArgValidationException exc = Assert.Throws <ArgValidationException>(() =>
            {
                Arg.Validate(() => nullValue).Contains("");
            });

            Assert.Equal($"Argument '{nameof(nullValue)}' is null. Can not execute 'Contains' method", exc.Message);
        }
Example #9
0
        public void In_ListIsNull_ArgValidationException()
        {
            var value = new object();

            object[] nullArgument = null;

            ArgValidationException exc = Assert.Throws <ArgValidationException>(() => Arg.Validate(() => value).In(nullArgument));

            Assert.Equal("Argument 'values' is null. There are no values to compare", exc.Message);
        }
        public void InRange_MinEqualsMax_ArgValidationException()
        {
            int value = 2;
            int min   = 1;
            int max   = min;

            ArgValidationException exc = Assert.Throws <ArgValidationException>(() => Arg.Validate(() => value).InRange(min, max));

            Assert.Equal("Argument 'min' cannot be more or equals 'max'. Cannot define range", exc.Message);
        }
Example #11
0
        public void Contains_ValueIsNull_ArgValidationException()
        {
            string arg                 = "value";
            string nullValue           = null;
            ArgValidationException exc = Assert.Throws <ArgValidationException>(() =>
            {
                Arg.Validate(() => arg).Contains(nullValue);
            });

            Assert.Equal($"Argument 'value' of method 'Contains' is null. Can not execute 'Contains' method", exc.Message);
        }
        public void MoreThan_MoreThanArgumentIsNull_ArgValidationException()
        {
            ComparableClass        value        = new ComparableClass();
            ComparableClass        moreThanNull = null;
            ArgValidationException exc          = Assert.Throws <ArgValidationException>(() =>
            {
                Arg.Validate(() => value).MoreThan(moreThanNull);
            });

            Assert.Equal($"Argument 'value' of method 'MoreThan' is null. Сan not compare null object", exc.Message);
        }
        public void MoreThan_ArgumentIsNull_ArgValidationException()
        {
            ComparableClass        nullValue     = null;
            ComparableClass        moreThanValue = new ComparableClass();
            ArgValidationException exc           = Assert.Throws <ArgValidationException>(() =>
            {
                Arg.Validate(() => nullValue).MoreThan(moreThanValue);
            });

            Assert.Equal($"Argument '{nameof(nullValue)}' is null. Сan not compare null object", exc.Message);
        }