예제 #1
0
        public ApplicationForm(
            IValidationEngine validationEngine,
            IDatabaseSchemaGenerator generator,
            ILocalFileSchemaGenerator localGenerator,
            IParser parser,
            IDatabaseContextProvider contextProvider,
            ILogger logger,
            IFormatter formatter,
            IRichTextBoxStreamWriterFactory textStreamWriterFactory
            )
        {
            _validationEngine        = validationEngine;
            _generator               = generator;
            _localGenerator          = localGenerator;
            _parser                  = parser;
            _contextProvider         = contextProvider;
            _logger                  = logger;
            _formatter               = formatter;
            _textStreamWriterFactory = textStreamWriterFactory;

            InitializeComponent();

            RedirectConsoleOutputToTextBox();

            CenterToScreen();

            SetInitialScript();

            DisplayCheckboxesForValidationRules();

            CreateSchema();
        }
예제 #2
0
 public ValidationFacade(
     IUserRepository userRepository)
 {
     _validationEngine = new ValidationEngineFactory().Create(userRepository);
     _validationErrorFormattingEngine = new ValidationErrorFormattingEngineFactory().Create();
     _validationErrorsMerger          = new ValidationErrorsMerger();
 }
 internal void DisposeGraphValidation()
 {
     if (Validator != null)
     {
         Validator.Dispose();
         Validator = null;
     }
 }
예제 #4
0
 protected GridViewAutoBindColumn(GridViewBinder <TObjectType> parentBinder, PropertyInfo propertyInfo, IValidationEngine validationEngine, IGridColumnCreator columnCreator)
 {
     _propertyInfo         = propertyInfo;
     _validationEngine     = validationEngine;
     XtraColumn            = columnCreator.CreateFor <TPropertyType>(PropertyName, parentBinder.GridView);
     DefaultRepositoryItem = this.DefaultRepository();
     this.WithCaption(PropertyName);
 }
예제 #5
0
 protected IValidationEngine GetEngine(IQuery actual)
 {
     if (engine == null)
     {
         engine = new ValidationEngineFactory().Instantiate(actual);
     }
     return(engine);
 }
 public CreateCommandHandler(IRepository <TDomain, TId> repository, IValidationEngine validationEngine, IEnumerable <IPermision <TDomain> > permisionSet, ICreateHandlerFactory <TCreateCommand, TDomain> creator, IEnumerable <ICommandPermision <TCreateCommand, TDomain> > commandPermisions, IEnumerable <ICommandAction <TCreateCommand, TDomain> > preCommitActions)
 {
     _repository        = repository;
     _preCommitActions  = preCommitActions;
     _commandPermisions = commandPermisions;
     _creator           = creator.BuildCreator();
     _permisionSet      = permisionSet;
     _validationEngine  = validationEngine;
 }
예제 #7
0
 public UpdateCommandHandler(IRepository <TDomain, TId> repository, IValidationEngine validationEngine, IEnumerable <IPermision <TDomain> > permisionSet, IUpdateHandlerFactory <TUpdateCommand, TDomain> updaterFactory, IEnumerable <ICommandPermision <TUpdateCommand, TDomain> > commandPermisions, IEnumerable <ICommandAction <TUpdateCommand, TDomain> > preCommitActions)
 {
     _repository        = repository;
     _preCommitActions  = preCommitActions;
     _commandPermisions = commandPermisions;
     _updater           = updaterFactory.BuildUpdater();
     _permisionSet      = permisionSet;
     _validationEngine  = validationEngine;
 }
        public void BeforeAnyTestRuns()
        {

            this.ValidatorProvider = new DefaultValidatorProvider();
            this.ValidatorProvider.RegisterValidator(new SaveEmployeeValidator());
            this.ValidatorProvider.RegisterValidator(new SaveManagerValidator());

            this.ValidationEngine = new DefaultValidationEngine(this.ValidatorProvider);
            Simple.Validation.Validator.SetValidationEngine(this.ValidationEngine);
        }
예제 #9
0
 public ValuesProcessor(
     ILogger <ValuesProcessor> logger,
     IServiceProvider services,
     IValidationEngine validationEngine,
     IProcessorExecutionContext executionContext,
     IEnumerable <IValidator> validators)
     : base(logger, services, validationEngine, executionContext)
 {
     this._validators = validators;
 }
예제 #10
0
 protected BaseProcessor(
     ILogger <BaseProcessor <TRequest, TResponse> > logger,
     IServiceProvider serviceProvider,
     IValidationEngine validationEngine,
     IProcessorExecutionContext executionContext)
 {
     this.Logger           = logger;
     this.ValidationEngine = validationEngine;
     this.ServiceProvider  = serviceProvider;
     this.ProcessorContext = executionContext;
 }
예제 #11
0
 protected override void Context()
 {
     _source           = new AnImplementation();
     _elementList      = new List <IElementBinder <IAnInterface> >();
     _element1         = A.Fake <IElementBinder <IAnInterface> >();
     _element2         = A.Fake <IElementBinder <IAnInterface> >();
     _validationEngine = A.Fake <IValidationEngine>();
     sut = new ScreenBinder <IAnInterface>(_elementList);
     sut.AddElement(_element1);
     sut.AddElement(_element2);
 }
예제 #12
0
 public void FactoryOverride <T>(T service)
 {
     if (typeof(T) == typeof(ITwitterApiAccessor))
     {
         this.twitterAcc = (ITwitterApiAccessor)service;
     }
     else if (typeof(T) == typeof(IValidationEngine))
     {
         this.validationEng = (IValidationEngine)service;
     }
 }
예제 #13
0
 public ObsService(IFormRepository formRepository, IEncounterRepository encounterRepository,
                   IObsRepository obsRepository
                   , INavigationEngine navigationEngine, IValidationEngine validationEngine, IClientStateRepository clientStateRepository)
 {
     _formRepository        = formRepository;
     _encounterRepository   = encounterRepository;
     _obsRepository         = obsRepository;
     _navigationEngine      = navigationEngine;
     _validationEngine      = validationEngine;
     _clientStateRepository = clientStateRepository;
 }
예제 #14
0
        private void Init()
        {
            if (validationEng == null)
            {
                validationEng = new ValidationEngine();
            }

            if (twitterAcc == null)
            {
                twitterAcc = new TwitterAPIAccessor();
            }
        }
        protected override void Context()
        {
            _source       = A.Fake <IAnInterface>();
            _screenBinder = A.Fake <ScreenBinder <IAnInterface> >();

            _elementToValidate = A.Fake <IElementBinder <IAnInterface, string> >();
            A.CallTo(() => _elementToValidate.Source).Returns(_source);
            A.CallTo(() => _elementToValidate.PropertyName).Returns("FirstName");
            A.CallTo(() => _elementToValidate.GetValueFromControl()).Returns("Toto");
            _elementToValidate.ParentBinder = _screenBinder;

            _validationEngine = A.Fake <IValidationEngine>();
            sut = new ElementBinderValidator <IAnInterface, string>(_validationEngine);
        }
예제 #16
0
        private GridViewBoundColumn(GridViewBinder <TObjectType> parentBinder, PropertyInfo propertyInfo,
                                    IValidationEngine validationEngine, IGridColumnCreator gridColumnCreator)
        {
            _parentBinder     = parentBinder;
            _propertyInfo     = propertyInfo;
            _validationEngine = validationEngine;

            _cellBinders = new Cache <TObjectType, ICellBinder <TObjectType, TPropertyType> >(cell => cell.Source);

            XtraColumn            = gridColumnCreator.CreateFor <TPropertyType>(parentBinder.GridView);
            DefaultRepositoryItem = this.DefaultRepository();

            this.WithCaption(PropertyName);
        }
        public void SetUp()
        {
            _liveSetting = new LiveSetting(_database.DatabasePath);
            var formRepository = new FormRepository(_liveSetting,
                                                    new QuestionRepository(_liveSetting,
                                                                           new ConceptRepository(_liveSetting, new CategoryRepository(_liveSetting))));

            _formId    = TestDataHelpers._formId;
            _form      = formRepository.GetWithQuestions(_formId, true);
            _encounter = TestHelpers.CreateTestEncountersWithObs(_form);


            _validationEngine = new ValidationEngine();
            //[ValidatorId] Required | Range
            //[ValidatorTypeId] None | Numeric | Count
            //Revision=0
        }
예제 #18
0
 public void SetUp()
 {
     _liveSetting    = new LiveSetting(_database.DatabasePath);
     _formRepository = new FormRepository(_liveSetting,
                                          new QuestionRepository(_liveSetting,
                                                                 new ConceptRepository(_liveSetting, new CategoryRepository(_liveSetting))));
     _encounterRepository   = new EncounterRepository(_liveSetting);
     _obsRepository         = new ObsRepository(_liveSetting);
     _clientStateRepository = new ClientStateRepository(_liveSetting);
     _formId           = TestDataHelpers._formId;
     _form             = _formRepository.GetWithQuestions(_formId, true);
     _encounterNew     = TestHelpers.CreateTestEncounters(_form);
     _encounter        = TestHelpers.CreateTestEncountersWithObs(_form);
     _navigationEngine = new NavigationEngine();
     _validationEngine = new ValidationEngine();
     _obsService       = new ObsService(_formRepository, _encounterRepository, _obsRepository, _navigationEngine, _validationEngine, _clientStateRepository);
 }
예제 #19
0
        public GameManager(
            IGameDefinitionAccess gameDefinitionAccess
            , IGameSessionAccess gameSessionAccess
            , IPlayerAccess playerAccess
            , ITileAccess tileAccess
            , IGameBoardEngine gameBoardEngine
            , IGamePlayEngine gamePlayEngine
            , IValidationEngine validationEngine)
        {
            this.gameDefinitionAccess = gameDefinitionAccess;
            this.gameSessionAccess    = gameSessionAccess;
            this.playerAccess         = playerAccess;

            this.gameBoardEngine  = gameBoardEngine;
            this.gamePlayEngine   = gamePlayEngine;
            this.validationEngine = validationEngine;
        }
예제 #20
0
 public GameManager(
     IGameDefinitionAccess gameDefinitionAccess
     , IGameSessionAccess gameSessionAccess
     , IPlayerAccess playerAccess
     , IGameBoardEngine gameBoardEngine
     , IGamePlayEngine gamePlayEngine
     , IValidationEngine validationEngine
     , ILogger logger
     )
     : base(logger)
 {
     this.gameDefinitionAccess = gameDefinitionAccess;
     this.gameSessionAccess    = gameSessionAccess;
     this.playerAccess         = playerAccess;
     this.gameBoardEngine      = gameBoardEngine;
     this.gamePlayEngine       = gamePlayEngine;
     this.validationEngine     = validationEngine;
 }
        public void Matches_WithParsingError_ReturnFalse()
        {
            var mock = new Mock <IValidationEngine>();

            mock.Setup(engine => engine.Parse())
            .Returns(new ParserResult(new string[] { "parsing error" }));
            IValidationEngine qp = mock.Object;

            var syntacticallyCorrectConstraint = new SyntacticallyCorrectConstraint()
            {
                Engine = qp
            };

            //Method under test
            var res = syntacticallyCorrectConstraint.Matches(new SqlCommand());

            //Test conclusion
            Assert.That(res, Is.False);
        }
예제 #22
0
        public GridViewBinder(GridView gridView)
        {
            GridView = gridView;
            GridView.CustomRowCellEdit           += showCustomCellContent;
            GridView.CustomRowCellEditForEditing += showCustomCellEditForEditing;
            GridView.ShownEditor             += beforeShowingEditor;
            GridView.ValidatingEditor        += onValidatingEditor;
            GridView.ValidateRow             += onValidatingRow;
            GridView.CustomUnboundColumnData += onCustomUnboundColumnData;
            GridView.CustomColumnDisplayText += onCustomColumnDisplayText;
            GridView.CellValueChanged        += onCellValueChanged;
            GridView.InvalidRowException     += (o, e) => { e.ExceptionMode = ExceptionMode.NoAction; };
            BindingMode     = BindingMode.TwoWay;
            ValidationMode  = ValidationMode.LeavingCell;
            _boundColumns   = new Cache <string, IBoundColumn <T> >(col => col.ColumnName, s => null);
            _unboundColumns = new Cache <string, IColumn <T> >(col => col.ColumnName, s => null);

            _validationEngine = new ValidationEngine();
        }
        public void Matches_AnyIDbCommand_EngineParseCalledOnce()
        {
            var mock = new Mock <IValidationEngine>();

            mock.Setup(engine => engine.Parse())
            .Returns(ParserResult.NoParsingError());
            IValidationEngine qp = mock.Object;

            var syntacticallyCorrectConstraint = new SyntacticallyCorrectConstraint()
            {
                Engine = qp
            };

            var queryFoundry = new Mock <IQuery>();
            var query        = queryFoundry.Object;

            syntacticallyCorrectConstraint.Matches(query);

            //Test conclusion
            mock.Verify(engine => engine.Parse(), Times.Once());
        }
        public void Matches_NoParsingError_ReturnTrue()
        {
            var mock = new Mock <IValidationEngine>();

            mock.Setup(engine => engine.Parse())
            .Returns(ParserResult.NoParsingError());
            IValidationEngine qp = mock.Object;

            var syntacticallyCorrectConstraint = new SyntacticallyCorrectConstraint()
            {
                Engine = qp
            };

            var queryFoundry = new Mock <IQuery>();
            var query        = queryFoundry.Object;

            //Method under test
            var res = syntacticallyCorrectConstraint.Matches(query);

            //Test conclusion
            Assert.That(res, Is.True);
        }
예제 #25
0
 public CommandInvoker(IValidationEngine validationEngine, ICommandFactory handerFactory)
 {
     _validationEngine = validationEngine;
     _handerFactory = handerFactory;
 }
        public void methodName()
        {
            // Arrange
            this.ValidationEngine = Substitute.For<IValidationEngine>();

            var report = new Manager();

            // Act
            this.ValidationEngine.Validate(typeof(Manager), report, Arg.Is<string[]>(row => row.Contains("Save"))).Returns(new[] { new ValidationResult(), });

            // Assert

            var results = this.ValidationEngine.Validate(typeof (Manager), report, new[] {"Save"});
            Assert.That(results, Is.Not.Empty);
        }
예제 #27
0
 public CommandValidator(IValidationEngine validationEngine)
 {
     _validationEngine = validationEngine;
 }
예제 #28
0
 public CommandValidator(IValidationEngine validationEngine)
 {
     _validationEngine = validationEngine;
 }
예제 #29
0
 public ValidatableModel()
 {
     _validator = new ValidationEngine(this, OnErrorsChanged);
 }
        public void Cascade_Enumerable_InValidValues()
        {
            // Arrange
            this.ValidationEngine = Substitute.For<IValidationEngine>();
            Simple.Validation.Validator.SetValidationEngine(this.ValidationEngine);

            var validator = Properties<Manager>
                .For(e => e.Reports)
                .Cascade("Save")
                ;

            // Act
            var manager = new Manager();
            var reports = Builder<Manager>
                .CreateListOfSize(1)
                .All()
                .Do(m => m.Reports = Builder<Employee>
                    .CreateListOfSize(10)
                    .All()
                    .Build())
                .Build();

            manager.Reports = reports.Cast<Employee>().ToList();

            foreach(var report in reports)
            {
                this.ValidationEngine
                    .Validate(typeof(Manager), report, "Save")
                    .Returns(new []
                        {
                            new ValidationResult()
                                {
                                    PropertyName = "Age",
                                    Message = string.Format("Report {0} has an error", report.EmployeeId),
                                },
                        });
            }

            var results = validator.Validate(manager).ToList();

            // Assert
            Assert.That(results, Is.Not.Empty);
            for (var i = 0; i < manager.Reports.Count; i++)
            {
                var expectedPropertyName = string.Format("Reports[{0}].Age", i);
                var expectedResults = results.Where(vr => vr.PropertyName == expectedPropertyName).ToList();
                Assert.That(expectedResults, Is.Not.Empty);

                foreach (var expectedResult in expectedResults)
                {
                    Assert.That(expectedResult.Context == manager);
                }
            }
        }
 public CommandInvoker(IValidationEngine validationEngine, ICommandFactory handerFactory)
 {
     _validationEngine = validationEngine;
     _handerFactory    = handerFactory;
 }
예제 #32
0
 public ElementBinderValidator(IValidationEngine validationEngine)
 {
     _validationEngine = validationEngine;
 }