Example #1
0
        public ValidationResult Validate <T, TValidator>(T entity)
        {
            var validator = _autofacValidatorFactory.CreateInstance(typeof(TValidator));
            var result    = validator.Validate(entity);

            return(result);
        }
Example #2
0
        public void CreateInstance_ReturnValidator()
        {
            //Arrange
            var validator = new GetCustomerQueryValidator();
            var indexMock = new Mock <IIndex <Type, IValidator> >();

            indexMock.Setup(x => x[It.IsAny <Type>()])
            .Returns(validator);

            //Act
            var factory = new AutofacValidatorFactory(indexMock.Object);
            var result  = factory.CreateInstance(It.IsAny <Type>());

            //Assert
            result.Should().Be(validator);
        }