public void IsExists_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") } }; string folderPath = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData"); FileReader reader = new FileReader(folderPath); string xml = reader.Read("IsExists.xml"); //Дата --01-16 exists - false DateTime date = new DateTime(2017, 01, 16); MenologyRule rule = typiconEntity.GetMenologyRule(date); rule.RuleDefinition = xml; handler.Settings.Rule = rule; handler.Settings.DayWorships = rule.DayWorships; handler.Settings.Date = date; 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); //Дата --02-09 exists - true date = new DateTime(2017, 02, 09); rule = typiconEntity.GetMenologyRule(date); rule.RuleDefinition = xml; handler.Settings.Rule = rule; handler.Settings.DayWorships = rule.DayWorships; handler.Settings.Date = date; 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); }
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); }
public void CommonRuleElement_SimplePassing() { //находим первый попавшийся MenologyRule EFUnitOfWork _unitOfWork = new EFUnitOfWork(); //BookStorage.Instance = BookStorageFactory.Create(); GetTypiconEntityResponse resp = new TypiconEntityService(_unitOfWork).GetTypiconEntity(1); TypiconEntity typiconEntity = resp.TypiconEntity; MenologyRule rule = typiconEntity.MenologyRules[0]; ServiceSequenceHandler handler = new ServiceSequenceHandler(); handler.Settings = new RuleHandlerSettings() { Language = LanguageSettingsFactory.Create("cs-ru"), Rule = rule, Date = DateTime.Today }; string folderPath = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData"); FileReader reader = new FileReader(folderPath); string xml = reader.Read("CommonRuleElement_Simple.xml"); var element = TestRuleSerializer.Deserialize <WorshipSequence>(xml); element.Interpret(handler); var model = handler.GetResult(); //WorshipSequenceViewModel model = new WorshipSequenceViewModel(element, handler); Assert.AreEqual(30, model.FirstOrDefault()?.Count); }
public void YmnosStructureRule_FromRealDB() { 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("YmnosStructureRuleTest.xml"); //Дата --11-09 exists - true DateTime date = new DateTime(2017, 11, 09); 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); var model = handler.GetResult(); //SedalenRuleViewModel model = rule.GetRule<SedalenRule>(TestRuleSerializer.Root).CreateViewModel(handler) as SedalenRuleViewModel; Assert.AreEqual(3, rule.GetRule <SedalenRule>(TestRuleSerializer.Root).Structure.YmnosStructureCount); Assert.Pass(rule.GetRule <SedalenRule>(TestRuleSerializer.Root).Structure.YmnosStructureCount.ToString()); }
public void TheotokionRule_FromRealDB() { 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("TheotokionRuleTest.xml"); //Дата --01-16 exists - false DateTime date = new DateTime(2017, 01, 16); MenologyRule rule = typiconEntity.GetMenologyRule(date); rule.RuleDefinition = xml; handler.Settings.Rule = rule; handler.Settings.DayWorships = rule.DayWorships; handler.Settings.Date = date; rule.GetRule(TestRuleSerializer.Root).Interpret(handler); var model = handler.GetResult(); //KekragariaRuleViewModel model = rule.GetRule<KekragariaRule>(TestRuleSerializer.Root).CreateViewModel(handler) as KekragariaRuleViewModel; Assert.Pass(model.ToString()); Assert.IsNotNull(model); }
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); }