Beispiel #1
0
        public override IExpression GetInverse()
        {
            var seed = new List <List <IExpression> > {
                _elementaryExpressions
            };

            var expandedRepeatRepresentation = ExpandHelper.ExpandListRepresentation(seed, null, WasExpandedRepeatExpressionAddedToList);

            var intersectInverseList = expandedRepeatRepresentation.Select(GetInverseOfExpandedConcatRepresentation).ToList();

            return(new IntersectionExpression(intersectInverseList, _random));
        }
        public override IList <IStringBuilder> Expand()
        {
            var seedContent = RemoveTooLongExpressions(ExpansionLength, _concatExpressions)
                              .Select(concatExpression => concatExpression.Expand()).ToList();

            var seed = new List <List <IList <IStringBuilder> > > {
                seedContent
            };

            var expandedStringBuilderList = ExpandHelper.ExpandListRepresentation(seed, null, ExpandHelper.WasExpandedStringBuilderListAddedToList);

            return(MergeStringBuildersForEachUnion(expandedStringBuilderList));
        }
Beispiel #3
0
        public void ExpandListRepresentation_ReturnedListHasOneElement_WhenSeedContainsNoElementToBeExpanded()
        {
            ExpansionStatus  WasNotExpanded(List <int> expression, List <List <int> > expandedElements, int pos) => ExpansionStatus.NotExpanded;

            var seed = new List <List <int> > {
                new List <int> {
                    1
                }
            };

            var result = ExpandHelper.ExpandListRepresentation(seed, null, WasNotExpanded);

            Assert.AreEqual(1, result.Count);
        }
Beispiel #4
0
        public override IList <IStringBuilder> Expand()
        {
            var seed = new List <List <IExpression> > {
                _elementaryExpressions
            };

            var expandedRepeatRepresentation = ExpandHelper.ExpandListRepresentation(seed, ExpansionLength, WasExpandedRepeatExpressionAddedToList);

            var convertedExpressions = new List <List <IList <IStringBuilder> > >();

            foreach (var expressionList in expandedRepeatRepresentation)
            {
                var expandedExpression = expressionList.Select(x => x.Expand()).ToList();
                convertedExpressions.Add(expandedExpression);
            }

            var expandedUnionList = ExpandHelper.ExpandListRepresentation(convertedExpressions, ExpansionLength, ExpandHelper.WasExpandedStringBuilderListAddedToList);

            return(CreateConcatenatedStringBuilderForEachExpansion(expandedUnionList));
        }
Beispiel #5
0
        public void ExpandListRepresentation_ReturnedListHasThreeElements_WhenSeedContainsElementToBeExpandedIntoThreeSubelements()
        {
            ExpansionStatus WasExpanded(IEnumerable <int> expression, ICollection <List <int> > expandedElements, int pos)
            {
                foreach (var i in expression)
                {
                    expandedElements.Add(new List <int> {
                        i
                    });
                }

                return(ExpansionStatus.Expanded);
            }

            var seed = new List <List <int> > {
                new List <int> {
                    1, 2, 3
                }
            };

            var result = ExpandHelper.ExpandListRepresentation(seed, null, WasExpanded);

            Assert.AreEqual(3, result.Count);
        }