Example #1
0
        public void IncorrectUseOfValidationOnAttributes()
        {
            var attribs = new ArgumentValidationAttribute[]
            {
                new MustExistAttribute(PathExists.AsFile),
                new MustNotExistAttribute()
            };

            foreach (var attrib in attribs)
            {
                string reason;
                Action tryValidateWithNullContext = () => attrib.TryValidate(null, 0, out reason);
                tryValidateWithNullContext.ShouldThrow<ArgumentNullException>("because {0} shouldn't let it", attrib.GetType().Name);
            }
        }
Example #2
0
        public void IncorrectUseOfAcceptTypeOnAttributes()
        {
            var attribs = new ArgumentValidationAttribute[]
            {
                new MustExistAttribute(PathExists.AsFile),
                new MustNotBeEmptyAttribute()
            };

            foreach (var attrib in attribs)
            {
                Action acceptTypeWithNull = () => attrib.AcceptsType(null);
                acceptTypeWithNull.ShouldThrow<ArgumentNullException>();
            }
        }