Пример #1
0
        public void evaluating_conditions(string condition, bool?expected)
        {
            MSBuildConditionParser.TryParse(TestHelper.Monitor, condition, out BaseNode node)
            .Should().BeTrue();

            var ev = new PartialEvaluator();

            ev.PartialEvaluation(node).Should().Be(expected, $"{condition} should be {expected?.ToString() ?? "null"}.");
        }
Пример #2
0
 public void parsing_valid_simple_conditions(string c, string d)
 {
     MSBuildConditionParser.TryParse(TestHelper.Monitor, c, out BaseNode node).Should().BeTrue();
     if (d != null)
     {
         node.Should().NotBeNull();
         node.ToString().Should().Be(d);
     }
     else
     {
         node.Should().BeNull();
     }
 }
Пример #3
0
        public void evaluating_conditions_with_known_properties(string condition, string props, bool?expected)
        {
            var d = props.Split(',')
                    .Select(kv => kv.Split(':'))
                    .ToDictionary(kv => kv[0].Trim(), kv => kv[1].Trim());

            MSBuildConditionParser.TryParse(TestHelper.Monitor, condition, out BaseNode node)
            .Should().BeTrue();

            var ev = new PartialEvaluator();

            ev.PartialEvaluation(node, s => { d.TryGetValue(s, out var v); return(v); })
            .Should().Be(expected, $"{condition} should be {expected?.ToString() ?? "null"}.");
        }