Example #1
0
        protected void CheckFormulaIn(IUsingFormula entity, IFormula formulaToCheck, ResolveErrorBehavior resolveErrorBehavior)
        {
            var entityAbsolutePath = _objectPathFactory.CreateAbsoluteObjectPath(entity).ToPathString();
            var builder            = _buildConfiguration.BuilderFor(entity);
            var objectWithError    = builder ?? entity;
            var entityType         = _objectTypeResolver.TypeFor(entity);

            if (formulaToCheck.IsBlackBox())
            {
                addNotificationType(NotificationType.Error, objectWithError, Validation.FormulaIsBlackBoxIn(entity.Name, entityAbsolutePath));
                return;
            }

            foreach (var objectPath in formulaToCheck.ObjectPaths)
            {
                CheckPath(entity, objectPath, resolveErrorBehavior);
            }
        }
 protected override void Context()
 {
     _pathFactory  = new ObjectPathFactory(new AliasCreator());
     _userSettings = A.Fake <IUserSettings>();
     _userSettings.CheckDimensions = true;
     _buildConfiguration           = A.Fake <IBuildConfiguration>();
     A.CallTo(() => _buildConfiguration.BuilderFor(A <IObjectBase> ._)).ReturnsLazily(x => x.GetArgument <IObjectBase>(0));
     sut = new DimensionValidator(new DimensionParser(), _pathFactory, _userSettings);
 }
        private void addNotification(NotificationType notificationType, IObjectBase entityToValidate, string notification)
        {
            var builder = _buildConfiguration.BuilderFor(entityToValidate);

            if (!shouldShowNotification(entityToValidate, notification))
            {
                return;
            }

            _result.AddMessage(notificationType, builder, notification);
        }
Example #4
0
        protected void CheckFormulaIn(IUsingFormula entity, IFormula formulaToCheck, ResolveErrorBehavior resolveErrorBehavior)
        {
            var entityAbsolutePath = _objectPathFactory.CreateAbsoluteObjectPath(entity).ToPathString();
            var builder            = _buildConfiguration.BuilderFor(entity);
            var objectWithError    = builder ?? entity;

            // Dynamic formula may contain object path that will be resolved per instance. It cannot be checked here
            if (formulaToCheck.IsDynamic())
            {
                return;
            }


            if (formulaToCheck.IsBlackBox())
            {
                addNotificationType(NotificationType.Error, objectWithError, Validation.FormulaIsBlackBoxIn(entity.Name, entityAbsolutePath));
                return;
            }

            foreach (var objectPath in formulaToCheck.ObjectPaths)
            {
                CheckPath(entity, objectPath, resolveErrorBehavior);
            }
        }
        private void checkCircularReferencesIn(IUsingFormula usingFormula, IBuildConfiguration buildConfiguration, ValidationResult validationResult)
        {
            var references = _entityReferenceCache[usingFormula];

            if (!references.Contains(usingFormula))
            {
                return;
            }

            var entityAbsolutePath = _objectPathFactory.CreateAbsoluteObjectPath(usingFormula).ToPathString();
            var builder            = buildConfiguration.BuilderFor(usingFormula);
            var objectWithError    = builder ?? usingFormula;
            var entityType         = _objectTypeResolver.TypeFor(usingFormula);
            var allReferencesName  = references.Distinct().AllNames();

            validationResult.AddMessage(NotificationType.Error, objectWithError, Validation.CircularReferenceFoundInFormula(usingFormula.Name, entityType, entityAbsolutePath, allReferencesName));
        }
Example #6
0
        /// <summary>
        ///    Adds event group to source container where event takes place
        /// </summary>
        private void createEventGroupInContainer(IEventGroupBuilder eventGroupBuilder, IContainer sourceContainer)
        {
            //this creates recursively all event groups for the given builder
            var eventGroup = _eventGroupMapper.MapFrom(eventGroupBuilder, _buildConfiguration);

            sourceContainer.Add(eventGroup);

            //needs to add the requires transport into model only for the added event group
            foreach (var childEventGroup in eventGroup.GetAllContainersAndSelf <IEventGroup>())
            {
                var childEventGroupBuilder = _buildConfiguration.BuilderFor(childEventGroup).DowncastTo <IEventGroupBuilder>();
                if (childEventGroupBuilder is IApplicationBuilder applicationBuilder)
                {
                    addApplicationTransports(applicationBuilder, childEventGroup);
                }

                _keywordReplacerTask.ReplaceIn(childEventGroup, _model.Root, childEventGroupBuilder, _buildConfiguration.Molecules);
            }
        }