예제 #1
0
        public void IsCelebrating_Test()
        {
            //находим первый попавшийся MenologyRule
            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"), Date = DateTime.Today
                }
            };

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

            //Ektenis element = RuleFactory.CreateElement(xml) as Ektenis;


            //находим Праздничное правило
            MenologyRule rule = typiconEntity.GetMenologyRule(new DateTime(2017, 09, 28));

            rule.RuleDefinition = xml;

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

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

            var model = handler.GetResult();

            //var model = rule.GetRule<EktenisRule>(TestRuleSerializer.Root).CreateViewModel(handler) as EktenisViewModel;

            Assert.AreEqual(3, model.FirstOrDefault()?.Count);

            //а теперь находим правило НЕ праздничное
            rule = typiconEntity.GetMenologyRule(new DateTime(2017, 10, 15));
            rule.RuleDefinition = xml;

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

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

            model = handler.GetResult();

            //model = rule.GetRule<EktenisRule>(TestRuleSerializer.Root).CreateViewModel(handler) as EktenisViewModel;

            Assert.AreEqual(2, model.FirstOrDefault()?.Count);
        }
예제 #2
0
        public void IsCelebrating_Test()
        {
            ServiceSequenceHandler handler = new ServiceSequenceHandler()
            {
                Settings = new RuleHandlerSettings()
                {
                    Date = DateTime.Today
                }
            };

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

            //Ektenis element = RuleFactory.CreateElement(xml) as Ektenis;


            //находим Праздничное правило
            MenologyRule rule = TypiconVersion.GetMenologyRule(new DateTime(2017, 09, 28));

            rule.RuleDefinition = xml;

            handler.Settings.Menologies = rule.DayWorships.ToList();

            rule.GetRule <ExecContainer>(Serializer).Interpret(handler);

            var model = handler.ActualWorshipChildElements;

            //var model = rule.GetRule<EktenisRule>(TestRuleSerializer.Root).CreateViewModel(handler) as EktenisViewModel;

            Assert.AreEqual(3, model.Count);

            //а теперь находим правило НЕ праздничное
            rule = TypiconVersion.GetMenologyRule(new DateTime(2017, 10, 15));
            rule.RuleDefinition = xml;

            handler.Settings.Menologies = rule.DayWorships.ToList();

            handler.ClearResult();
            rule.GetRule <ExecContainer>(Serializer).Interpret(handler);

            model = handler.ActualWorshipChildElements;

            //model = rule.GetRule<EktenisRule>(TestRuleSerializer.Root).CreateViewModel(handler) as EktenisViewModel;

            Assert.AreEqual(2, model.Count);
        }
예제 #3
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());
        }
예제 #4
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);
        }
예제 #5
0
        public void IsTwoSaints_Test()
        {
            ServiceSequenceHandler handler = new ServiceSequenceHandler()
            {
                Settings = new RuleHandlerSettings()
                {
                    Date = DateTime.Today
                }
            };

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

            //Ektenis element = RuleFactory.CreateElement(xml) as Ektenis;


            //Минея - попразднество, 1 святой
            MenologyRule rule = TypiconVersion.GetMenologyRule(new DateTime(2017, 09, 28));

            rule.RuleDefinition = xml;

            handler.Settings.Menologies = rule.DayWorships.ToList();

            rule.GetRule <ExecContainer>(Serializer).Interpret(handler);

            var model = handler.ActualWorshipChildElements;

            //EktenisViewModel model = rule.GetRule<EktenisRule>(TestRuleSerializer.Root).CreateViewModel(handler) as EktenisViewModel;

            Assert.AreEqual(1, model.Count);

            //Триодь, Минея - 1 святой
            rule = TypiconVersion.GetMenologyRule(new DateTime(2017, 3, 16));
            rule.RuleDefinition = xml;

            TriodionRule triodRule = TypiconVersion.GetTriodionRule(-20);

            handler.Settings.Menologies = rule.DayWorships.ToList();
            handler.Settings.Triodions  = triodRule.DayWorships.ToList();

            handler.ClearResult();
            rule.GetRule <ExecContainer>(Serializer).Interpret(handler);

            model = handler.ActualWorshipChildElements;

            //model = rule.GetRule<EktenisRule>(TestRuleSerializer.Root).CreateViewModel(handler) as EktenisViewModel;

            Assert.AreEqual(1, model.Count);

            //а теперь находим правило НЕ праздничное, 2 святых
            rule = TypiconVersion.GetMenologyRule(new DateTime(2017, 5, 31));
            rule.RuleDefinition = xml;

            handler.Settings.Menologies = rule.DayWorships.ToList();

            handler.ClearResult();
            rule.GetRule <ExecContainer>(Serializer).Interpret(handler);

            model = handler.ActualWorshipChildElements;

            //model = rule.GetRule<EktenisRule>(TestRuleSerializer.Root).CreateViewModel(handler) as EktenisViewModel;

            Assert.AreEqual(2, model.Count);
        }
예제 #6
0
        public void IsTwoSaints_Test()
        {
            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"), Date = DateTime.Today
                }
            };

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

            //Ektenis element = RuleFactory.CreateElement(xml) as Ektenis;


            //Минея - попразднество, 1 святой
            MenologyRule rule = typiconEntity.GetMenologyRule(new DateTime(2017, 09, 28));

            rule.RuleDefinition = xml;

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

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

            var model = handler.GetResult();

            //EktenisViewModel model = rule.GetRule<EktenisRule>(TestRuleSerializer.Root).CreateViewModel(handler) as EktenisViewModel;

            Assert.AreEqual(1, model.FirstOrDefault()?.Count);

            //Триодь, Минея - 1 святой
            rule = typiconEntity.GetMenologyRule(new DateTime(2017, 3, 16));
            rule.RuleDefinition = xml;

            TriodionRule triodRule = typiconEntity.GetTriodionRule(-20);

            rule.DayWorships.AddRange(triodRule.DayWorships);

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

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

            model = handler.GetResult();

            //model = rule.GetRule<EktenisRule>(TestRuleSerializer.Root).CreateViewModel(handler) as EktenisViewModel;

            Assert.AreEqual(1, model.FirstOrDefault()?.Count);

            //а теперь находим правило НЕ праздничное, 2 святых
            rule = typiconEntity.GetMenologyRule(new DateTime(2017, 5, 31));
            rule.RuleDefinition = xml;

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

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

            model = handler.GetResult();

            //model = rule.GetRule<EktenisRule>(TestRuleSerializer.Root).CreateViewModel(handler) as EktenisViewModel;

            Assert.AreEqual(2, model.FirstOrDefault()?.Count);
        }