public void Expand_ReturnsListContaining3ElementsOfLength4_WhenOneExpandableExpressionWith3PossibleSubexpressionsIsContained()
        {
            var mockA = new StringBuilderMock(ToCharacterClassList("a"));
            var mock1 = new StringBuilderMock(ToCharacterClassList("1"));
            var mock2 = new StringBuilderMock(ToCharacterClassList("2"));
            var mock3 = new StringBuilderMock(ToCharacterClassList("3"));

            var simpleExpression = Substitute.For <IExpression>();

            simpleExpression.RepeatRange = new IntegerInterval(1);

            simpleExpression.Expand().Returns(new List <IStringBuilder> {
                mockA
            });

            var expandableExpression = Substitute.For <IExpression>();

            expandableExpression.RepeatRange = new IntegerInterval(1);
            expandableExpression.Expand().Returns(new List <IStringBuilder> {
                mock1, mock2, mock3
            });

            var concat = new ConcatenationExpression(_random);

            concat.SetExpansionLength(4);
            concat.Append(simpleExpression).Append(expandableExpression).Append(simpleExpression).Append(simpleExpression);

            var result = concat.Expand();

            Assert.AreEqual(3, result.Count);
            Assert.AreEqual("a1aa", result[0].GenerateString());
            Assert.AreEqual("a2aa", result[1].GenerateString());
            Assert.AreEqual("a3aa", result[2].GenerateString());
        }
        public void Expand_DoesNotChangeRepeatRangeValue_WhenCalled()
        {
            var clone = Substitute.For <IExpression>();

            clone.Expand().Returns(new List <IStringBuilder> {
                new StringBuilderMock(new List <CharacterClassExpression>())
            });
            var expression = Substitute.For <IExpression>();

            expression.Clone().Returns(clone);
            expression.RepeatRange = new IntegerInterval();
            expression.RepeatRange.TrySetValue(1, 3);
            var concat = new ConcatenationExpression(_random);

            concat.Append(expression);

            concat.Expand();

            Assert.AreEqual(1, expression.RepeatRange.Start);
            Assert.AreEqual(3, expression.RepeatRange.End);
        }
        public void Expand_ReturnsListContainingTwoElements_WhenSingleNotExpandableExpressionWithRepeatRangeFrom1To3IsContainedAndMaxExpansionLengthIs2()
        {
            var clone = Substitute.For <IExpression>();

            clone.Expand().Returns(new List <IStringBuilder> {
                new StringBuilderMock(new List <CharacterClassExpression>())
            });
            clone.ExpansionLength.Returns(2);
            var expression = Substitute.For <IExpression>();

            expression.Clone().Returns(clone);
            expression.RepeatRange = new IntegerInterval();
            expression.RepeatRange.TrySetValue(1, 3);
            expression.ExpansionLength.Returns(2);
            var concat = new ConcatenationExpression(_random);

            concat.Append(expression);
            concat.SetExpansionLength(2);

            var result = concat.Expand();

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