public void IAsAdditionElement_IsMatchContinue()
        {
            // rule/worship
            var worship = new WorshipRule("worship", new RootContainer("rule"), TestRuleSerializer.Create().QueryProcessor);

            // rule/worship/kanonasrule/odi
            var kanonasRule = new KanonasRule("kanonasrule"
                                              , new KanonasRuleVMFactory(TestRuleSerializer.Create())
                                              , new WorshipRule("worship", new RootContainer("rule"), TestRuleSerializer.Create().QueryProcessor));

            kanonasRule.ChildElements.Add(new KOdiRule("odi", kanonasRule));

            var result = kanonasRule.IsMatch(worship);

            Assert.AreEqual(AsAdditionMatchingResult.Continue, result);
        }
示例#2
0
        public void KanonasRule_FromDB()
        {
            DateTime date = new DateTime(2017, 11, 11);
            string   xml  = TestDataXmlReader.GetXmlString("KanonasRuleTest.xml");

            ServiceSequenceHandler handler = new ServiceSequenceHandler()
            {
                Settings = RuleHandlerSettingsTestFactory.Create(1, date, xml)
            };

            handler.ClearResult();
            KanonasRule kanonasRule = TestRuleSerializer.Deserialize <KanonasRule>(xml);

            kanonasRule.Interpret(handler);

            Assert.AreEqual(4, kanonasRule.Odes[0].Kanones.Count());
        }
示例#3
0
        public void KanonasRule_FromDB()
        {
            EFUnitOfWork _unitOfWork = new EFUnitOfWork();
            //BookStorage.Instance = BookStorageFactory.Create();
            GetTypiconEntityResponse resp          = new TypiconEntityService(_unitOfWork).GetTypiconEntity(1);
            TypiconEntity            typiconEntity = resp.TypiconEntity;

            ServiceSequenceHandler handler = new ServiceSequenceHandler()
            {
                Settings = new RuleHandlerSettings()
                {
                    Language = LanguageSettingsFactory.Create("cs-ru")
                }
            };

            string     folderPath = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData");
            FileReader reader     = new FileReader(folderPath);
            string     xml        = reader.Read("KanonasRuleTest.xml");

            DateTime date = new DateTime(2017, 11, 11);

            MenologyRule rule = typiconEntity.GetMenologyRule(date);

            rule.RuleDefinition = xml;

            handler.Settings.Rule        = rule;
            handler.Settings.DayWorships = rule.DayWorships;
            handler.Settings.Date        = date;

            var bookStorage = BookStorageFactory.Create();

            OktoikhDay oktoikhDay = bookStorage.Oktoikh.Get(date);

            handler.Settings.OktoikhDay = oktoikhDay;

            //rule.GetRule(TestRuleSerializer.Root).Interpret(handler);

            handler.ClearResult();
            KanonasRule kanonasRule = rule.GetRule <KanonasRule>(TestRuleSerializer.Root);

            kanonasRule.Interpret(handler);

            Assert.AreEqual(4, kanonasRule.Kanones.Count());
            //Assert.IsNotNull(kanonasRule.Sedalen);
        }
        public void IAsAdditionElement_IsMatchFail2()
        {
            // rule/worship/kanonasrule/odi
            var element = new KanonasRule("kanonasrule"
                                          , new KanonasRuleVMFactory(TestRuleSerializer.Create())
                                          , new WorshipRule("worship", new RootContainer("rule"), TestRuleSerializer.Create().QueryProcessor));

            var odi = new KOdiRule("odi", element);

            element.ChildElements.Add(odi);

            // rule/worship/kanonasrule/after
            var toMatch = new KanonasRule("kanonasrule"
                                          , new KanonasRuleVMFactory(TestRuleSerializer.Create())
                                          , new WorshipRule("worship", new RootContainer("rule"), TestRuleSerializer.Create().QueryProcessor));
            var after = new KAfterRule("after", element);

            element.ChildElements.Add(after);

            var result = odi.IsMatch(after);

            Assert.AreEqual(AsAdditionMatchingResult.Fail, result);
        }