Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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>();
            }
        }