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"}."); }
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(); } }
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"}."); }