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

            foreach (var attrib in attribs)
            {
                Action tryValidateWithNullContext = () => attrib.TryValidate(null, 0, out string reason);
                tryValidateWithNullContext.ShouldThrow <ArgumentNullException>("because {0} shouldn't let it", attrib.GetType().Name);
            }
        }
예제 #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>();
            }
        }