Exemplo n.º 1
0
        public void PerformValidationIsValidReturnTrueWithValidEntities()
        {
            //Arrange
            var entityA = new EntityWithValidationAttribute();

            entityA.RequiredProperty = "the data";

            var entityB = new EntityWithValidatableObject();

            entityB.RequiredProperty = "the data";

            IEntityValidator entityValidator = EntityValidatorFactory.CreateValidator();

            //Act
            var entityAValidationResult = entityValidator.IsValid(entityA);
            var entityAInvalidMessages  = entityValidator.GetInvalidMessages(entityA);
            var entityBValidationResult = entityValidator.IsValid(entityB);
            var entityBInvalidMessages  = entityValidator.GetInvalidMessages(entityB);

            //Assert
            Assert.True(entityAValidationResult);
            Assert.True(entityBValidationResult);
            Assert.False(entityAInvalidMessages.Any());
            Assert.False(entityBInvalidMessages.Any());
        }
Exemplo n.º 2
0
      public void PerformValidationIsValidReturnTrueWithValidEntities()
      {
         //Arrange
         var entityA = new EntityWithValidationAttribute();
         entityA.RequiredProperty = "the data";

         var entityB = new EntityWithValidatableObject();
         entityB.RequiredProperty = "the data";

         var entityValidator = EntityValidatorFactory.CreateValidator();

         //Act
         var entityAValidationResult = entityValidator.IsValid(entityA);
         var entityAInvalidMessages = entityValidator.GetInvalidMessages(entityA);

         var entityBValidationResult = entityValidator.IsValid(entityB);
         var entityBInvalidMessages = entityValidator.GetInvalidMessages(entityB);

         //Assert
         Assert.IsTrue(entityAValidationResult);
         Assert.IsTrue(entityBValidationResult);

         Assert.IsFalse(entityAInvalidMessages.Any());
         Assert.IsFalse(entityBInvalidMessages.Any());

      }