public void RuleSerializerRoot_Additional()
        {
            var unitOfWork = TestRuleSerializer.Create();

            var factoryContainer = unitOfWork.Container <RuleExecutable, ICalcStructureElement>();

            Assert.IsNotNull(factoryContainer);
            Assert.Pass(factoryContainer.ToString());
        }
        public void RuleSerializerRoot_If()
        {
            var unitOfWork = TestRuleSerializer.Create();

            var factoryContainer = unitOfWork.Container <If>();

            Assert.IsNotNull(factoryContainer);
            Assert.Pass(factoryContainer.ToString());
        }
Пример #3
0
        public void Validate_FromDB()
        {
            var dbContext = TypiconDbContextFactory.Create();

            var version = dbContext.Set <TypiconVersion>().First(c => c.Id == 1);

            var errs = version.GetBrokenConstraints(TestRuleSerializer.Create());

            Assert.AreEqual(errs.Count, 0);
        }
        public static CalculateModifiedYearJobHandler Build(TypiconDBContext dbContext, JobRepository jobRepo)
        {
            var query   = DataQueryProcessorFactory.Create(dbContext);
            var command = CommandProcessorFactory.Create(dbContext);

            var serializerRoot = TestRuleSerializer.Create(dbContext);

            var settingsFactory = new RuleHandlerSettingsFactory(serializerRoot);

            return(new CalculateModifiedYearJobHandler(dbContext, settingsFactory, jobRepo));
        }
        public void ModifyReplacedDay_Xml()
        {
            string xmlString = @"<modifyreplacedday daymove=""0"" kind=""menology""/>";

            var serializer = TestRuleSerializer.Create();

            var element = serializer.Container <ModifyReplacedDay>()
                          .Deserialize(xmlString);

            Assert.AreEqual(KindOfReplacedDay.Menology, element.Kind);
        }
        public void IAsAdditionElement_IsMatchSuccess()
        {
            // rule/worship
            var worship = new WorshipRule("worship", new RootContainer("rule"), TestRuleSerializer.Create().QueryProcessor);

            // rule/worship
            var toMatch = new WorshipRule("worship", new RootContainer("rule"), TestRuleSerializer.Create().QueryProcessor);

            var result = worship.IsMatch(toMatch);

            Assert.AreEqual(AsAdditionMatchingResult.Success, result);
        }
Пример #7
0
        public static CalculateOutputFormWeekJobHandler Build(TypiconDBContext dbContext, JobRepository jobRepo)
        {
            var query = DataQueryProcessorFactory.Create(dbContext);

            var serializerRoot = TestRuleSerializer.Create(dbContext);

            var settingsFactory = new RuleHandlerSettingsFactory(serializerRoot);

            var outputFormFactory = new OutputDayFactory(new MajorDataCalculator(query, settingsFactory)
                                                         , new ScheduleDayNameComposer(query)
                                                         , serializerRoot.TypiconSerializer
                                                         , new ServiceSequenceHandler());

            return(new CalculateOutputFormWeekJobHandler(dbContext, outputFormFactory, jobRepo));
        }
Пример #8
0
        public void Rules_Expressions_Int_RightNumber()
        {
            string xmlString = "<int>-15</int>";

            var unitOfWork = TestRuleSerializer.Create();

            var element = unitOfWork.Container <Int>()
                          .Deserialize(new XmlDescriptor()
            {
                Description = xmlString
            }, null);

            Assert.IsNotNull(element);

            Assert.AreEqual(-15, element.ValueCalculated);
        }
        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);
        }
        public void TypiconVariablesTest_Serialization()
        {
            //создаем объект
            var container = TestWorshipContainer;

            var serializer = TestRuleSerializer.Create();
            //сериализуем его
            var xml = serializer.TypiconSerializer.Serialize(container);

            //пытаемся скормить для десериализации в реальные правила
            var c = serializer.Container <ExecContainer>().Deserialize(xml);

            //проверяем значения

            var worships = c.GetChildElements <WorshipRule>(new RuleHandlerSettings());

            Assert.AreEqual(1, worships.Count(c => c.Mode == WorshipMode.DayBefore));
            Assert.AreEqual(2, worships.Count(c => c.Mode == WorshipMode.ThisDay));
        }
Пример #11
0
        public void Validate_MadeByHands()
        {
            TypiconVersion version = new TypiconVersion()
            {
                Id = 1,
                //Name = new ItemText()
                //{
                //    Items = new List<ItemTextUnit>() { new ItemTextUnit("cs-ru", "Типикон") }
                //},
                Signs = new List <Sign>()
                {
                    new Sign()
                    {
                        Id = 1
                    }
                }
            };

            var errs = version.GetBrokenConstraints(TestRuleSerializer.Create());

            Assert.Greater(errs.Count, 0);
        }
        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);
        }
Пример #13
0
        private OutputDayFactory Build()
        {
            var dbContext = TypiconDbContextFactory.Create();

            var query = DataQueryProcessorFactory.Create(dbContext);

            var serializerRoot = TestRuleSerializer.Create(dbContext);

            var settingsFactory = new RuleHandlerSettingsFactory(serializerRoot);

            var dataCalculator = new ExplicitDataCalculator(query,
                                                            new AsAdditionDataCalculator(query,
                                                                                         new TransparentDataCalculator(query,
                                                                                                                       new MajorDataCalculator(query, settingsFactory)
                                                                                                                       , settingsFactory)
                                                                                         , settingsFactory)
                                                            , settingsFactory);

            return(new OutputDayFactory(dataCalculator
                                        , new ScheduleDayNameComposer(query)
                                        , serializerRoot.TypiconSerializer
                                        , new ServiceSequenceHandler()));
        }
Пример #14
0
        public void TextHolder_Creature()
        {
            #region xml
            string xmlString = @"<rule>
	                                <deacon>
		                                <p>
			                                <item language=""cs-ru"">Миром Господу помолимся.</item>
		                                </p>
	                                </deacon>
	                                <choir>
		                                <p>
			                                <item language=""cs-ru"">Господи, помилуй.</item>
		                                </p>
	                                </choir>
	                                <deacon>
		                                <p>
			                                <item language=""cs-ru"">Пресвятую, Пречистую, Преблагословенную, Славную Владычицу Нашу Богородицу, и Приснодеву Марию со всеми святыми помянувши сами себя, и друг друга, и весь живот наш Христу Богу предадим.</item>
		                                </p>
	                                </deacon>
	                                <choir>
		                                <p>
			                                <item language=""cs-ru"">Тебе Господи.</item>
		                                </p>
	                                </choir>
	                                <priest>
		                                <p>
			                                <item language=""cs-ru"">Яко подобает Тебе всякая слава, честь и поклонение, Отцу, и Сыну, и Святому Духу, всегда, ныне и присно, и во веки веков.</item>
		                                </p>
	                                </priest>
	                                <choir>
		                                <p>
			                                <item language=""cs-ru"">Аминь.</item>
		                                </p>
	                                </choir>
	                                <lector>
		                                <p>
			                                <item language=""cs-cs"">Положи́, Го́споди, хране́ние усто́м мои́м, и дверь огражде́ния о устна́х мои́х.</item>
		                                </p>
	                                </lector>
                                </rule>";
            #endregion

            var serializer = TestRuleSerializer.Create();

            var element = serializer.Container <ExecContainer>()
                          .Deserialize(new XmlDescriptor()
            {
                Description = xmlString
            }, null);
            //3
            int choirCount = element.ChildElements.Where(c => (c is TextHolder) && (c as TextHolder).Kind == TextHolderKind.Choir).Count();
            //2
            int deaconCount = element.ChildElements.Where(c => (c is TextHolder) && (c as TextHolder).Kind == TextHolderKind.Deacon).Count();
            //1
            int priestCount = element.ChildElements.Where(c => (c is TextHolder) && (c as TextHolder).Kind == TextHolderKind.Priest).Count();
            //1
            int lectorCount = element.ChildElements.Where(c => (c is TextHolder) && (c as TextHolder).Kind == TextHolderKind.Lector).Count();

            Assert.AreEqual(choirCount, 3);
            Assert.AreEqual(deaconCount, 2);
            Assert.AreEqual(priestCount, 1);
            Assert.AreEqual(lectorCount, 1);
            Assert.IsTrue(element.IsValid);
            Assert.Pass("Ok");
        }