Пример #1
0
        public void TestTryLoadExistingRulesList()
        {
            DirectoryInfo   di = new DirectoryInfo(rulesFolder);
            RulesRepository rr = new RulesRepository("testRules", di);

            string ruleListFile = string.Format("{0}{1}{2}.rul", rulesFolder, Path.DirectorySeparatorChar, rr.Name);

            if (!File.Exists(ruleListFile))
            {
                rr.TryLoadNewRulesList();
                rr.TrySaveRulesList();
                if (!File.Exists(ruleListFile))
                {
                    Assert.Fail("Can not run test TestTryLoadExistingRulesList.  No existing rule file was found, and a new one could not be created");
                }
            }

            rr.TryLoadExistingRulesList();
            Assert.AreEqual(2, rr.MyRules.Count, "Invalid number of Rules loaded by TryLoadRulesList");
            foreach (Rule currentRule in rr.MyRules.Values)
            {
                switch (currentRule.FriendlyName)
                {
                case "SetValue":
                case "IncrementValue":
                    break;

                default:
                    Assert.Fail("Unexpected rule file loaded from the Repository.");
                    break;
                }
            }
        }
Пример #2
0
        public void TestTryLoadExistingRulesList()
        {
            DirectoryInfo di = new DirectoryInfo(rulesFolder);
            RulesRepository rr = new RulesRepository("testRules", di);

            string ruleListFile = string.Format("{0}{1}{2}.rul", rulesFolder, Path.DirectorySeparatorChar, rr.Name);
            if (!File.Exists(ruleListFile))
            {
                rr.TryLoadNewRulesList();
                rr.TrySaveRulesList();
                if (!File.Exists(ruleListFile))
                {
                    Assert.Fail("Can not run test TestTryLoadExistingRulesList.  No existing rule file was found, and a new one could not be created");
                }
            }

            rr.TryLoadExistingRulesList();
            Assert.AreEqual(2, rr.MyRules.Count, "Invalid number of Rules loaded by TryLoadRulesList");
            foreach (Rule currentRule in rr.MyRules.Values)
            {
                switch (currentRule.FriendlyName)
                {
                    case "SetValue":
                    case "IncrementValue":
                        break;
                    default:
                        Assert.Fail("Unexpected rule file loaded from the Repository.");
                        break;
                }
            }
        }