Example #1
0
        protected override void Context()
        {
            _projectRetriever = A.Fake <IMoBiProjectRetriever>();
            sut = new TagVisitor(_projectRetriever);

            _spatialStructure = new MoBiSpatialStructure();
            var topContainer = new Container().WithName("Top");

            topContainer.AddTag("Top");
            var sub1 = new Container().WithName("Sub1");

            sub1.AddTag("sub");
            var sub2 = new Container().WithName("Sub2");

            sub2.Add(new Parameter().WithName(AppConstants.Param));
            sub2.Add(new DistributedParameter().WithName("Param2"));
            sub2.AddTag("sub");
            topContainer.Add(sub1);
            topContainer.Add(sub2);

            var neighborHoods = new Container().WithName("N");

            neighborHoods.AddTag("N");
            _spatialStructure.NeighborhoodsContainer = neighborHoods;
            _spatialStructure.AddTopContainer(topContainer);

            var molecules = new Container().WithName(Constants.MOLECULE_PROPERTIES);

            molecules.AddTag(Constants.MOLECULE_PROPERTIES);
            _spatialStructure.GlobalMoleculeDependentProperties = molecules;

            var mobiProject = new MoBiProject();

            mobiProject.AddBuildingBlock(_spatialStructure);

            A.CallTo(() => _projectRetriever.Current).Returns(mobiProject);
        }
Example #2
0
        public bool Filter(DisplayFilterRowInfo rowInfo, bool success)
        {
            if (!rowInfo.IsSegment)
            {
                return(!HasCustomSettings());
            }

            var rowId = rowInfo.SegmentPair.Properties.Id.Id;

            if (success && _customSettings.EvenNo)
            {
                success = SegmentNumbersHelper.IsEven(rowId);
            }

            if (success && _customSettings.OddsNo)
            {
                success = SegmentNumbersHelper.IsOdd(rowId);
            }

            if (success && _customSettings.SplitSegments)
            {
                success = SegmentNumbersHelper.IsSplitSegment(rowId, _document);
            }

            if (success && (_customSettings.MergedSegments || _customSettings.MergedAcross))
            {
                success = SegmentNumbersHelper.IsMergedSegment(rowId, _document, _customSettings.MergedAcross);
            }

            if (success && _customSettings.SourceEqualsTarget)
            {
                success = SegmentNumbersHelper.IsSourceEqualsToTarget(rowInfo.SegmentPair, _customSettings.IsEqualsCaseSensitive);
            }

            if (success && _customSettings.Grouped && !string.IsNullOrWhiteSpace(_customSettings.GroupedList))
            {
                success = SegmentNumbersHelper.IdInRange(rowId, _customSettings.GroupedList);
            }

            if (success && _customSettings.UseRegexCommentSearch && !string.IsNullOrWhiteSpace(_customSettings.CommentRegex))
            {
                var visitor = new CommentDataVisitor();

                var commentsList = visitor.GetComments(rowInfo.SegmentPair.Source);
                commentsList.AddRange(visitor.GetComments(rowInfo.SegmentPair.Target));

                success = CommentsHelper.IsCommentTextFoundWithRegex(commentsList, _customSettings.CommentRegex);
            }

            if (success && _customSettings.Colors?.Count > 0)
            {
                success = ColorPickerHelper.ContainsColor(rowInfo, _customSettings.Colors, _customSettings.ColorsFoundIn);
            }

            if (success && !string.IsNullOrWhiteSpace(_customSettings.FuzzyMin) && !string.IsNullOrWhiteSpace(_customSettings.FuzzyMax))
            {
                success = FuzzyHelper.IsInFuzzyRange(rowInfo, _customSettings.FuzzyMin, _customSettings.FuzzyMax);
            }

            if (success && _customSettings.ContainsTags)
            {
                var containsTagVisitor = new TagVisitor();
                success = containsTagVisitor.ContainsTag(rowInfo.SegmentPair.Source);
            }

            if (success && _customSettings.CreatedByChecked && !string.IsNullOrWhiteSpace(_customSettings.CreatedBy))
            {
                var userVisitor = new TranslationOriginMetaDataVisitor();
                success = userVisitor.CreatedBy(rowInfo.SegmentPair.Source, _customSettings.CreatedBy);
            }

            if (success && _customSettings.ModifiedByChecked && !string.IsNullOrWhiteSpace(_customSettings.ModifiedBy))
            {
                var userVisitor = new TranslationOriginMetaDataVisitor();
                success = userVisitor.ModifiedBy(rowInfo.SegmentPair.Source, _customSettings.ModifiedBy);
            }

            if (success && !string.IsNullOrEmpty(_customSettings.DocumentStructureInformation))
            {
                success = _settings.IsRegularExpression
                                        ? DocumentStructureInfoRegexSearch(rowInfo, _customSettings.DocumentStructureInformation,
                                                                           _settings.IsCaseSensitive
                                                        ? RegexOptions.None
                                                        : RegexOptions.IgnoreCase)
                                        : DocumentStructureInfoSearch(rowInfo, _customSettings);
            }

            return(success);
        }