コード例 #1
0
        public void SetUp()
        {
            _validationCollectorProviderMock        = MockRepository.GenerateStrictMock <IValidationCollectorProvider>();
            _validationCollectorMergerMock          = MockRepository.GenerateStrictMock <IValidationCollectorMerger>();
            _metaRulesValidatorFactoryStub          = MockRepository.GenerateStub <IMetaRulesValidatorFactory>();
            _metaRuleValidatorMock                  = MockRepository.GenerateStrictMock <IMetaRuleValidator>();
            _validationRuleGlobalizationServiceMock = MockRepository.GenerateStrictMock <IValidationRuleMetadataService>();
            _memberInformationNameResolverMock      = MockRepository.GenerateStrictMock <IMemberInformationNameResolver>();
            _collectorValidatorMock                 = MockRepository.GenerateStrictMock <ICollectorValidator> ();

            _metaValidationRule1Stub = MockRepository.GenerateStub <IAddingComponentPropertyMetaValidationRule>();
            _metaValidationRule2Stub = MockRepository.GenerateStub <IAddingComponentPropertyMetaValidationRule>();
            _metaValidationRule3Stub = MockRepository.GenerateStub <IAddingComponentPropertyMetaValidationRule>();

            _componenValidationCollectorStub1 = MockRepository.GenerateStub <IComponentValidationCollector>();
            _componenValidationCollectorStub1.Stub(stub => stub.AddedPropertyMetaValidationRules).Return(new[] { _metaValidationRule1Stub });
            _componenValidationCollectorStub2 = MockRepository.GenerateStub <IComponentValidationCollector>();
            _componenValidationCollectorStub2.Stub(stub => stub.AddedPropertyMetaValidationRules)
            .Return(new[] { _metaValidationRule2Stub, _metaValidationRule3Stub });
            _componenValidationCollectorStub3 = MockRepository.GenerateStub <IComponentValidationCollector>();
            _componenValidationCollectorStub3.Stub(stub => stub.AddedPropertyMetaValidationRules)
            .Return(new IAddingComponentPropertyMetaValidationRule[0]);

            _validationCollectorInfo1 = new ValidationCollectorInfo(
                _componenValidationCollectorStub1,
                typeof(ApiBasedComponentValidationCollectorProvider));
            _validationCollectorInfo2 = new ValidationCollectorInfo(
                _componenValidationCollectorStub2,
                typeof(ApiBasedComponentValidationCollectorProvider));
            _validationCollectorInfo3 = new ValidationCollectorInfo(
                _componenValidationCollectorStub3,
                typeof(ApiBasedComponentValidationCollectorProvider));

            _validationRuleStub1 = MockRepository.GenerateStub <IValidationRule>();
            _validationRuleStub2 = MockRepository.GenerateStub <IValidationRule>();
            _validationRuleStub3 = PropertyRule.Create(ExpressionHelper.GetTypedMemberExpression <Customer, string> (c => c.FirstName));
            _validationRuleStub4 = PropertyRule.Create(ExpressionHelper.GetTypedMemberExpression <Customer, string> (c => c.LastName));

            _fakeValidationRuleResult           = new[] { _validationRuleStub1, _validationRuleStub2, _validationRuleStub3, _validationRuleStub4 };
            _fakeValidationCollectorMergeResult = new ValidationCollectorMergeResult(_fakeValidationRuleResult, MockRepository.GenerateStub <ILogContext>());

            _fluentValidationBuilder = new FluentValidatorBuilder(
                _validationCollectorProviderMock,
                _validationCollectorMergerMock,
                _metaRulesValidatorFactoryStub,
                _validationRuleGlobalizationServiceMock,
                _memberInformationNameResolverMock,
                _collectorValidatorMock);

            _validMetaValidationResult1   = MetaValidationRuleValidationResult.CreateValidResult();
            _validMetaValidationResult2   = MetaValidationRuleValidationResult.CreateValidResult();
            _invalidMetaValidationResult1 = MetaValidationRuleValidationResult.CreateInvalidResult("Error1");
            _invalidMetaValidationResult2 = MetaValidationRuleValidationResult.CreateInvalidResult("Error2");
        }
コード例 #2
0
        public void SetUp()
        {
            _validationRuleStub = MockRepository.GenerateStub <IValidationRule>();
            _typeToValidate     = typeof(Customer);

            _validationRuleGlobalizationServiceMock1 = MockRepository.GenerateStrictMock <IValidationRuleMetadataService>();
            _validationRuleGlobalizationServiceMock2 = MockRepository.GenerateStrictMock <IValidationRuleMetadataService>();
            _validationRuleGlobalizationServiceMock3 = MockRepository.GenerateStrictMock <IValidationRuleMetadataService>();

            _service =
                new CompoundValidationRuleMetadataService(
                    new[] { _validationRuleGlobalizationServiceMock1, _validationRuleGlobalizationServiceMock2, _validationRuleGlobalizationServiceMock3 });
        }
コード例 #3
0
        public FluentValidatorBuilder(
            IValidationCollectorProvider validationCollectorProvider,
            IValidationCollectorMerger validationCollectorMerger,
            IMetaRulesValidatorFactory metaRuleValidatorFactory,
            IValidationRuleMetadataService validationRuleGlobalizationService,
            IMemberInformationNameResolver memberInformationNameResolver,
            ICollectorValidator collectorValidator)
        {
            ArgumentUtility.CheckNotNull("validationCollectorProvider", validationCollectorProvider);
            ArgumentUtility.CheckNotNull("validationCollectorMerger", validationCollectorMerger);
            ArgumentUtility.CheckNotNull("metaRuleValidatorFactory", metaRuleValidatorFactory);
            ArgumentUtility.CheckNotNull("validationRuleGlobalizationService", validationRuleGlobalizationService);
            ArgumentUtility.CheckNotNull("memberInformationNameResolver", memberInformationNameResolver);
            ArgumentUtility.CheckNotNull("collectorValidator", collectorValidator);

            _validationCollectorProvider        = validationCollectorProvider;
            _validationCollectorMerger          = validationCollectorMerger;
            _metaRulesValidatorFactory          = metaRuleValidatorFactory;
            _validationRuleGlobalizationService = validationRuleGlobalizationService;
            _memberInformationNameResolver      = memberInformationNameResolver;
            _collectorValidator = collectorValidator;
        }