Пример #1
0
        public void GetConstraint_Build_HandleVariable()
        {
            var sutXmlStubFactory  = new Mock <Systems.ExecutionXml>();
            var itemXmlStubFactory = new Mock <QueryableXml>();

            itemXmlStubFactory.Setup(i => i.GetQuery()).Returns("query");
            sutXmlStubFactory.Setup(s => s.Item).Returns(itemXmlStubFactory.Object);
            var sutXml = sutXmlStubFactory.Object;

            sutXml.Item = itemXmlStubFactory.Object;

            var ctrXml = new AllRowsXml();

            ctrXml.Predicate                = new PredicateXml();
            ctrXml.Predicate.MoreThan       = new MoreThanXml();
            ctrXml.Predicate.MoreThan.Value = "@year";

            var variables = new Dictionary <string, ITestVariable>()
            {
                { "year", new CSharpTestVariable("DateTime.Now.Year") }
            };

            var builder = new ExecutionAllRowsBuilder();

            builder.Setup(sutXml, ctrXml, null, variables);
            builder.Build();

            Assert.That(variables["year"].IsEvaluated, Is.True);
        }
Пример #2
0
        public void GetConstraint_BuildWithResultSet_CorrectConstraint()
        {
            var sutXmlStubFactory  = new Mock <Systems.ExecutionXml>();
            var itemXmlStubFactory = new Mock <QueryableXml>();

            itemXmlStubFactory.Setup(i => i.GetQuery()).Returns("query");
            sutXmlStubFactory.Setup(s => s.Item).Returns(itemXmlStubFactory.Object);
            var sutXml = sutXmlStubFactory.Object;

            sutXml.Item = itemXmlStubFactory.Object;

            var ctrXml = new AllRowsXml();

            ctrXml.Predicate                = new PredicateXml();
            ctrXml.Predicate.MoreThan       = new MoreThanXml();
            ctrXml.Predicate.MoreThan.Value = "100";

            var builder = new ExecutionAllRowsBuilder();

            builder.Setup(sutXml, ctrXml);
            builder.Build();
            var ctr = builder.GetConstraint();

            Assert.That(ctr, Is.InstanceOf <AllRowsConstraint>());
            var allRows = ctr as AllRowsConstraint;

            Assert.That(allRows.Child, Is.Null);
        }