Beispiel #1
0
        private void UpdateUI()
        {
            btnRemoveRuleDefinition.Enabled = CurrentCollection?.Internal == false;
            btnUp.Enabled   = CurrentCollection?.Internal == false && Analyzer.ExternalRuleCollections.IndexOf(CurrentCollection) > 0;
            btnDown.Enabled = CurrentCollection?.Internal == false && Analyzer.ExternalRuleCollections.IndexOf(CurrentCollection) < Analyzer.ExternalRuleCollections.Count - 1;

            btnNewRule.Enabled    = CurrentCollection?.AllowEdit == true;
            btnEditRule.Enabled   = CurrentRules.Count() == 1 && (CurrentCollection ?? Analyzer.EffectiveCollectionForRule(CurrentRules.FirstOrDefault().ID)).AllowEdit;
            btnClone.Enabled      = CurrentCollection?.AllowEdit == true && CurrentRules.Count() == 1 && (CurrentCollection ?? Analyzer.EffectiveCollectionForRule(CurrentRules.FirstOrDefault().ID)).AllowEdit;
            btnDeleteRule.Enabled = CurrentRules.Any() && CurrentRules.All(r => (CurrentCollection ?? Analyzer.EffectiveCollectionForRule(r.ID)).AllowEdit);
            btnMoveTo.Enabled     = CurrentRules.Any();
        }
Beispiel #2
0
        public void TestMethod1()
        {
            var h = new TabularModelHandler(ModelFile);
            var a = new Analyzer();

            a.SetModel(h.Model, ModelFolder);

            Assert.AreEqual(2, a.ExternalRuleCollections.Count);

            Assert.AreEqual(LocalMachineRules, a.LocalMachineRules.FilePath);
            Assert.AreEqual(6, a.LocalMachineRules.Rules.Count);

            Assert.AreEqual(LocalUserRules, a.LocalUserRules.FilePath);
            Assert.AreEqual(5, a.LocalUserRules.Rules.Count);

            Assert.AreEqual(Environment.CurrentDirectory + @"\AbsolutePathRules.json", a.ExternalRuleCollections[1].FilePath);
            Assert.AreEqual(4, a.ExternalRuleCollections[1].Rules.Count);

            Assert.AreEqual("RelativePathRules.json", a.ExternalRuleCollections[0].FilePath);
            Assert.AreEqual(3, a.ExternalRuleCollections[0].Rules.Count);

            Assert.IsNull(a.ModelRules.FilePath);
            Assert.AreEqual(2, a.ModelRules.Rules.Count);

            Assert.AreEqual(20, a.AllRules.Count());
            Assert.AreEqual(10, a.EffectiveRules.Count());

            Assert.AreSame(a.ModelRules, a.EffectiveCollectionForRule("RULE1"));
            Assert.AreSame(a.ExternalRuleCollections[0], a.EffectiveCollectionForRule("RULE2"));
            Assert.AreSame(a.ExternalRuleCollections[1], a.EffectiveCollectionForRule("RULE3"));
            Assert.AreSame(a.LocalUserRules, a.EffectiveCollectionForRule("RULE4"));
            Assert.AreSame(a.LocalMachineRules, a.EffectiveCollectionForRule("RULE5"));

            Assert.AreSame(a.ModelRules, a.EffectiveCollectionForRule("CM_RULE1"));
            Assert.AreSame(a.ExternalRuleCollections[0], a.EffectiveCollectionForRule("RP_RULE1"));
            Assert.AreSame(a.ExternalRuleCollections[1], a.EffectiveCollectionForRule("AP_RULE1"));
            Assert.AreSame(a.LocalUserRules, a.EffectiveCollectionForRule("LU_RULE1"));
            Assert.AreSame(a.LocalMachineRules, a.EffectiveCollectionForRule("LM_RULE1"));
        }