Ejemplo n.º 1
0
        /// Use when you want to add some parameters to specification
        public void CannotAcceptPersonWithMyNameAndMyEmail()
        {
            //given
            var person = new Person()
            {
                FirstName = "Douglas",
                LastName  = "Franco",
                Email     = "*****@*****.**"
            };

            //when
            var result = _personValidator
                         .AddParameter("MyEmail", "*****@*****.**")
                         .AddParameter("MyFirstName", "Douglas")
                         .AddParameter("MyLastName", "Franco")
                         .IsValid(person);

            foreach (var item in _personValidator.InvalidRules)
            {
                Console.WriteLine(item);
            }

            //then
            Assert.IsFalse(result);
            Assert.AreEqual(_personValidator.InvalidRules.Count, 2);
            Assert.IsNotNull(_personValidator.InvalidRules.FirstOrDefault(x => (PersonValidation)x == PersonValidation.InvalidName));
            Assert.IsNotNull(_personValidator.InvalidRules.FirstOrDefault(x => (PersonValidation)x == PersonValidation.InvalidEmail));
        }