Exemple #1
0
        public void TestEndlessRecursiveEvaluation()
        {
            var context = new TestEvaluationContext {
                { "Foo", "$(Bar)" },
                { "Bar", "Hello $(Baz)" },
                { "Baz", "$(Foo)" }
            };

            Assert.Throws <Exception> (() => context.Evaluate("$(Foo)"));
        }
Exemple #2
0
        public void TestEvaluation(string expr, string expected)
        {
            var context = new TestEvaluationContext {
                { "Foo", "XfooX" },
                { "Bar", "YbarY" }
            };

            var evaluated = context.Evaluate(expr);

            Assert.AreEqual(expected, evaluated);
        }
Exemple #3
0
        public void TestRecursiveEvaluation()
        {
            var context = new TestEvaluationContext {
                { "Foo", "$(Bar)" },
                { "Bar", "Hello $(Baz)" },
                { "Baz", "World" }
            };

            var evaluated = context.Evaluate("$(Foo)");

            Assert.AreEqual("Hello World", evaluated);
        }
Exemple #4
0
        public void TestPermutedEvaluation(object[] args)
        {
            var expr = (string)args[0];

            var context = new TestEvaluationContext {
                { "Foo", new MSBuildPropertyValue(new[] { "One", "Two", "Three" }.Select(t => new ExpressionText(0, t, true)).ToArray()) },
                { "Bar", "Hello $(Baz)" },
                { "Baz", new MSBuildPropertyValue(new[] { "X", "Y" }.Select(t => new ExpressionText(0, t, true)).ToArray()) }
            };

            var results = context.EvaluateWithPermutation(expr).ToList();

            Assert.AreEqual(args.Length - 1, results.Count);
            for (int i = 0; i < args.Length - 1; i++)
            {
                Assert.AreEqual(args[i + 1], results[i]);
            }
        }