Exemplo n.º 1
0
        public void ToSingleRegexString_ReturnsEmptyString_WhenUnionIsEmpty()
        {
            var union = new UnionExpressionTest(new List<IExpression>(), _randomGenerator);

            var result = union.ToSingleStringBuilder().GenerateString();

            Assert.AreEqual(string.Empty, result);
        }
Exemplo n.º 2
0
        public void GetInverse_ReturnValueHasTypeUnionExpression()
        {
            var union = new UnionExpressionTest(new List<IExpression>(), _randomGenerator);

            var result = union.GetInverse();

            Assert.IsInstanceOf<IntersectionExpression>(result);
        }
Exemplo n.º 3
0
        public void ToSingleRegexString_ReturnsStringValueOfFirstUnionElement_WhenUnionContainsOneElement()
        {
            var union = new UnionExpressionTest(new List<IExpression> {_expression}, _randomGenerator);

            var result = union.ToSingleStringBuilder().GenerateString();

            Assert.AreEqual("Claudia", result);
            _expression.Received(1).ToStringBuilder();
        }
Exemplo n.º 4
0
        public void GetInverse_ReturnValueHasSameRepeatIntegerIntervalAsOriginal()
        {
            var repeatRange = new IntegerInterval();
            repeatRange.TrySetValue(1, 2);
            var union = new UnionExpressionTest(new List<IExpression>(), _randomGenerator) {RepeatRange = repeatRange};

            var result = union.GetInverse().RepeatRange;

            Assert.AreEqual(repeatRange, result);
        }
Exemplo n.º 5
0
        public void GetInverse_CallsGetComplementOnEachUnionElement()
        {
            var expression1 = Substitute.For<IExpression>();
            var expression2 = Substitute.For<IExpression>();
            var unionExpressions = new List<IExpression> {expression1, expression2};
            var union = new UnionExpressionTest(unionExpressions, _randomGenerator);

            union.GetInverse();

            expression1.Received(1).GetInverse();
            expression2.Received(1).GetInverse();
        }
Exemplo n.º 6
0
        public void ToSingleRegexString_ReturnsRandomUnionElement_WhenUnionContainsAtLeastTwoElements()
        {
            _randomGenerator.GetNextInteger(Arg.Any<int>(), Arg.Any<int>()).Returns(2);
            var unionExpressions = new List<IExpression>
            {
                Substitute.For<IExpression>(),
                Substitute.For<IExpression>(),
                _expression,
                Substitute.For<IExpression>()
            };
            var union = new UnionExpressionTest(unionExpressions, _randomGenerator);

            var result = union.ToSingleStringBuilder().GenerateString();

            Assert.AreEqual("Claudia", result);
            _expression.Received(1).ToStringBuilder();
            _randomGenerator.Received(1).GetNextInteger(Arg.Any<int>(), Arg.Any<int>());
        }