Exemplo n.º 1
0
        public void test_Except_of_traits()
        {
            CKTrait m1 = Context.FindOrCreate("Beta+Alpha+Fridge+Combo");
            CKTrait m2 = Context.FindOrCreate("Xtra+Combo+Another+Fridge+Alt");

            Assert.That(m1.Except(m2).ToString() == "Alpha+Beta", "Works as expected :-)");
            Assert.That(m2.Except(m1).ToString() == "Alt+Another+Xtra", "Works as expected...");

            Assert.That(m2.Except(Context.EmptyTrait) == m2 && m1.Except(Context.EmptyTrait) == m1, "Removing empty does nothing.");
        }
Exemplo n.º 2
0
        public void test_Except_of_traits()
        {
            var     c  = ContextWithPlusSeparator();
            CKTrait m1 = c.FindOrCreate("Beta+Alpha+Fridge+Combo");
            CKTrait m2 = c.FindOrCreate("Xtra+Combo+Another+Fridge+Alt");

            m1.Except(m2).ToString().Should().Be("Alpha+Beta", "Works as expected :-)");
            m2.Except(m1).ToString().Should().Be("Alt+Another+Xtra", "Works as expected...");

            m2.Except(c.EmptyTrait).Should().BeSameAs(m2, "Removing empty does nothing.");
            m1.Except(c.EmptyTrait).Should().BeSameAs(m1, "Removing empty does nothing.");
        }
Exemplo n.º 3
0
        CKTrait ComputeFrameworks(IActivityMonitor m, XElement e, PartialEvaluator evaluator)
        {
            CKTrait frameworks = TargetFrameworks;

            foreach (var framework in TargetFrameworks.AtomicTraits)
            {
                foreach (var(E, C) in e.AncestorsAndSelf()
                         .Select(x => (E: x, C: (string)x.Attribute("Condition")))
                         .Where(x => x.C != null))
                {
                    bool?include = evaluator.EvalFinalResult(m, C, f => f == "$(TargetFramework)" ? framework.ToString() : null);
                    if (include == null)
                    {
                        m.Error($"Unable to evaluate condition of {E}.");
                        return(null);
                    }
                    if (include == false)
                    {
                        frameworks = frameworks.Except(framework);
                    }
                }
            }
            return(frameworks);
        }