public void GetInverse_ReturnsIntersectExpressionWithTwoSubexpressionsOfLength3_WhenOriginalExpressionContains3SubExpressionsWithMiddleExpressionOfRepeatIntervalFrom1To2()
        {
            var repeatInterval = new IntegerInterval();

            repeatInterval.TrySetValue(1, 2);
            var inverseSubExpression = Substitute.For <IExpression>();

            inverseSubExpression.GetInverse().Returns(Substitute.For <IExpression>());
            var subExpression = Substitute.For <IExpression>();

            subExpression.GetInverse().Returns(inverseSubExpression);
            subExpression.RepeatRange.Returns(repeatInterval);
            subExpression.ExpansionLength.Returns(2);
            var concatExpression = new ConcatenationExpression(_randomGenerator);

            concatExpression.Append(inverseSubExpression).Append(subExpression).Append(inverseSubExpression);

            var result = concatExpression.GetInverse();

            Assert.IsInstanceOf <IntersectionExpression>(result);

            var resultAsList = ((IntersectionExpression)result).ToConcatExpressionList();

            Assert.AreEqual(2, resultAsList.Count);
            Assert.AreEqual(3, ((UnionExpression)resultAsList[0]).ToIntersectionExpressionList().Count);
            Assert.AreEqual(4, ((UnionExpression)resultAsList[1]).ToIntersectionExpressionList().Count);
        }
        public void GetInverse_ReturnsIntersectExpressionWithTwoSubexpressionsEachHavingRepeatIntervalNull_WhenOriginalExpressionContainsSingleSubExpressionWithRepeatIntervalFrom1To2()
        {
            var repeatInterval = new IntegerInterval();

            repeatInterval.TrySetValue(1, 2);
            var inverseSubExpression = Substitute.For <IExpression>();
            var subExpression        = Substitute.For <IExpression>();

            subExpression.GetInverse().Returns(inverseSubExpression);
            subExpression.RepeatRange.Returns(repeatInterval);
            subExpression.ExpansionLength.Returns(2);
            var concatExpression = new ConcatenationExpression(_randomGenerator);

            concatExpression.Append(subExpression);

            var result = concatExpression.GetInverse();

            Assert.IsInstanceOf <IntersectionExpression>(result);

            var resultAsList = ((IntersectionExpression)result).ToConcatExpressionList();

            Assert.AreEqual(2, resultAsList.Count);
            Assert.IsNull(resultAsList[0].RepeatRange);
            Assert.IsNull(resultAsList[1].RepeatRange);
        }