Exemple #1
0
        public void Search()
        {
            using (var searchEngine = new LexEntrySearchEngine(Cache))
            {
                var          entryFactory = Cache.ServiceLocator.GetInstance <ILexEntryFactory>();
                IMoMorphType stem         = Cache.ServiceLocator.GetInstance <IMoMorphTypeRepository>().GetObject(MoMorphTypeTags.kguidMorphStem);
                ILexEntry    form1        = entryFactory.Create(stem, Cache.TsStrFactory.MakeString("form1", Cache.DefaultVernWs), "gloss1", new SandboxGenericMSA());
                ILexEntry    form2        = entryFactory.Create(stem, Cache.TsStrFactory.MakeString("form2", Cache.DefaultVernWs), "gloss2", new SandboxGenericMSA());
                ILexEntry    form3        = entryFactory.Create(stem, Cache.TsStrFactory.MakeString("form3", Cache.DefaultVernWs), "gloss3", new SandboxGenericMSA());

                m_actionHandler.EndUndoTask();

                Assert.That(searchEngine.Search(new[] { new SearchField(LexEntryTags.kflidLexemeForm, Cache.TsStrFactory.MakeString("fo", Cache.DefaultVernWs)) }),
                            Is.EquivalentTo(new[] { form1.Hvo, form2.Hvo, form3.Hvo }));

                Assert.That(searchEngine.Search(new[] { new SearchField(LexEntryTags.kflidLexemeForm, Cache.TsStrFactory.MakeString("form1", Cache.DefaultVernWs)) }),
                            Is.EquivalentTo(new[] { form1.Hvo }));

                Assert.That(searchEngine.Search(new[] { new SearchField(LexEntryTags.kflidLexemeForm, Cache.TsStrFactory.MakeString("form4", Cache.DefaultVernWs)) }),
                            Is.Empty);

                Assert.That(searchEngine.Search(new[] { new SearchField(LexSenseTags.kflidGloss, Cache.TsStrFactory.MakeString("gl", Cache.DefaultAnalWs)) }),
                            Is.EquivalentTo(new[] { form1.Hvo, form2.Hvo, form3.Hvo }));
            }
        }
		public void Search()
		{
			using (var searchEngine = new LexEntrySearchEngine(Cache))
			{
				var entryFactory = Cache.ServiceLocator.GetInstance<ILexEntryFactory>();
				IMoMorphType stem = Cache.ServiceLocator.GetInstance<IMoMorphTypeRepository>().GetObject(MoMorphTypeTags.kguidMorphStem);
				ILexEntry form1 = entryFactory.Create(stem, Cache.TsStrFactory.MakeString("form1", Cache.DefaultVernWs), "gloss1", new SandboxGenericMSA());
				ILexEntry form2 = entryFactory.Create(stem, Cache.TsStrFactory.MakeString("form2", Cache.DefaultVernWs), "gloss2", new SandboxGenericMSA());
				ILexEntry form3 = entryFactory.Create(stem, Cache.TsStrFactory.MakeString("form3", Cache.DefaultVernWs), "gloss3", new SandboxGenericMSA());

				m_actionHandler.EndUndoTask();

				Assert.That(searchEngine.Search(new[] { new SearchField(LexEntryTags.kflidLexemeForm, Cache.TsStrFactory.MakeString("fo", Cache.DefaultVernWs)) }),
					Is.EquivalentTo(new[] {form1.Hvo, form2.Hvo, form3.Hvo}));

				Assert.That(searchEngine.Search(new[] { new SearchField(LexEntryTags.kflidLexemeForm, Cache.TsStrFactory.MakeString("form1", Cache.DefaultVernWs)) }),
					Is.EquivalentTo(new[] { form1.Hvo }));

				Assert.That(searchEngine.Search(new[] { new SearchField(LexEntryTags.kflidLexemeForm, Cache.TsStrFactory.MakeString("form4", Cache.DefaultVernWs)) }),
					Is.Empty);

				Assert.That(searchEngine.Search(new[] { new SearchField(LexSenseTags.kflidGloss, Cache.TsStrFactory.MakeString("gl", Cache.DefaultAnalWs)) }),
					Is.EquivalentTo(new[] { form1.Hvo, form2.Hvo, form3.Hvo }));
			}
		}
Exemple #3
0
        public void ResetIndex()
        {
            using (var searchEngine = new LexEntrySearchEngine(Cache))
            {
                var          entryFactory = Cache.ServiceLocator.GetInstance <ILexEntryFactory>();
                IMoMorphType stem         = Cache.ServiceLocator.GetInstance <IMoMorphTypeRepository>().GetObject(MoMorphTypeTags.kguidMorphStem);
                ILexEntry    form1        = entryFactory.Create(stem, Cache.TsStrFactory.MakeString("form1", Cache.DefaultVernWs), "gloss1", new SandboxGenericMSA());
                ILexEntry    form2        = entryFactory.Create(stem, Cache.TsStrFactory.MakeString("form2", Cache.DefaultVernWs), "gloss2", new SandboxGenericMSA());
                ILexEntry    form3        = entryFactory.Create(stem, Cache.TsStrFactory.MakeString("form3", Cache.DefaultVernWs), "gloss3", new SandboxGenericMSA());

                m_actionHandler.EndUndoTask();

                Assert.That(searchEngine.Search(new[] { new SearchField(LexEntryTags.kflidLexemeForm, Cache.TsStrFactory.MakeString("fo", Cache.DefaultVernWs)) }),
                            Is.EquivalentTo(new[] { form1.Hvo, form2.Hvo, form3.Hvo }));
                Assert.That(searchEngine.Search(new[] { new SearchField(LexSenseTags.kflidGloss, Cache.TsStrFactory.MakeString("gl", Cache.DefaultAnalWs)) }),
                            Is.EquivalentTo(new[] { form1.Hvo, form2.Hvo, form3.Hvo }));

                m_actionHandler.BeginUndoTask("Undo doing stuff", "Redo doing stuff");
                ILexEntry form4 = entryFactory.Create(stem, Cache.TsStrFactory.MakeString("form4", Cache.DefaultVernWs), "gloss4", new SandboxGenericMSA());
                m_actionHandler.EndUndoTask();

                Assert.That(searchEngine.Search(new[] { new SearchField(LexEntryTags.kflidLexemeForm, Cache.TsStrFactory.MakeString("fo", Cache.DefaultVernWs)) }),
                            Is.EquivalentTo(new[] { form1.Hvo, form2.Hvo, form3.Hvo, form4.Hvo }));
                Assert.That(searchEngine.Search(new[] { new SearchField(LexSenseTags.kflidGloss, Cache.TsStrFactory.MakeString("gl", Cache.DefaultAnalWs)) }),
                            Is.EquivalentTo(new[] { form1.Hvo, form2.Hvo, form3.Hvo, form4.Hvo }));

                m_actionHandler.BeginUndoTask("Undo doing stuff", "Redo doing stuff");
                form1.Delete();
                m_actionHandler.EndUndoTask();

                Assert.That(searchEngine.Search(new[] { new SearchField(LexEntryTags.kflidLexemeForm, Cache.TsStrFactory.MakeString("fo", Cache.DefaultVernWs)) }),
                            Is.EquivalentTo(new[] { form2.Hvo, form3.Hvo, form4.Hvo }));
                Assert.That(searchEngine.Search(new[] { new SearchField(LexSenseTags.kflidGloss, Cache.TsStrFactory.MakeString("gl", Cache.DefaultAnalWs)) }),
                            Is.EquivalentTo(new[] { form2.Hvo, form3.Hvo, form4.Hvo }));

                m_actionHandler.BeginUndoTask("Undo doing stuff", "Redo doing stuff");
                form2.LexemeFormOA.Form.SetVernacularDefaultWritingSystem("other");
                form2.SensesOS[0].Gloss.SetAnalysisDefaultWritingSystem("other");
                m_actionHandler.EndUndoTask();

                Assert.That(searchEngine.Search(new[] { new SearchField(LexEntryTags.kflidLexemeForm, Cache.TsStrFactory.MakeString("fo", Cache.DefaultVernWs)) }),
                            Is.EquivalentTo(new[] { form3.Hvo, form4.Hvo }));
                Assert.That(searchEngine.Search(new[] { new SearchField(LexSenseTags.kflidGloss, Cache.TsStrFactory.MakeString("gl", Cache.DefaultAnalWs)) }),
                            Is.EquivalentTo(new[] { form3.Hvo, form4.Hvo }));
            }
        }
		public void ResetIndex()
		{
			using (var searchEngine = new LexEntrySearchEngine(Cache))
			{
				var entryFactory = Cache.ServiceLocator.GetInstance<ILexEntryFactory>();
				IMoMorphType stem = Cache.ServiceLocator.GetInstance<IMoMorphTypeRepository>().GetObject(MoMorphTypeTags.kguidMorphStem);
				ILexEntry form1 = entryFactory.Create(stem, Cache.TsStrFactory.MakeString("form1", Cache.DefaultVernWs), "gloss1", new SandboxGenericMSA());
				ILexEntry form2 = entryFactory.Create(stem, Cache.TsStrFactory.MakeString("form2", Cache.DefaultVernWs), "gloss2", new SandboxGenericMSA());
				ILexEntry form3 = entryFactory.Create(stem, Cache.TsStrFactory.MakeString("form3", Cache.DefaultVernWs), "gloss3", new SandboxGenericMSA());

				m_actionHandler.EndUndoTask();

				Assert.That(searchEngine.Search(new[] { new SearchField(LexEntryTags.kflidLexemeForm, Cache.TsStrFactory.MakeString("fo", Cache.DefaultVernWs)) }),
					Is.EquivalentTo(new[] { form1.Hvo, form2.Hvo, form3.Hvo }));
				Assert.That(searchEngine.Search(new[] { new SearchField(LexSenseTags.kflidGloss, Cache.TsStrFactory.MakeString("gl", Cache.DefaultAnalWs)) }),
					Is.EquivalentTo(new[] { form1.Hvo, form2.Hvo, form3.Hvo }));

				m_actionHandler.BeginUndoTask("Undo doing stuff", "Redo doing stuff");
				ILexEntry form4 = entryFactory.Create(stem, Cache.TsStrFactory.MakeString("form4", Cache.DefaultVernWs), "gloss4", new SandboxGenericMSA());
				m_actionHandler.EndUndoTask();

				Assert.That(searchEngine.Search(new[] { new SearchField(LexEntryTags.kflidLexemeForm, Cache.TsStrFactory.MakeString("fo", Cache.DefaultVernWs)) }),
					Is.EquivalentTo(new[] { form1.Hvo, form2.Hvo, form3.Hvo, form4.Hvo }));
				Assert.That(searchEngine.Search(new[] { new SearchField(LexSenseTags.kflidGloss, Cache.TsStrFactory.MakeString("gl", Cache.DefaultAnalWs)) }),
					Is.EquivalentTo(new[] { form1.Hvo, form2.Hvo, form3.Hvo, form4.Hvo }));

				m_actionHandler.BeginUndoTask("Undo doing stuff", "Redo doing stuff");
				form1.Delete();
				m_actionHandler.EndUndoTask();

				Assert.That(searchEngine.Search(new[] { new SearchField(LexEntryTags.kflidLexemeForm, Cache.TsStrFactory.MakeString("fo", Cache.DefaultVernWs)) }),
					Is.EquivalentTo(new[] { form2.Hvo, form3.Hvo, form4.Hvo }));
				Assert.That(searchEngine.Search(new[] { new SearchField(LexSenseTags.kflidGloss, Cache.TsStrFactory.MakeString("gl", Cache.DefaultAnalWs)) }),
					Is.EquivalentTo(new[] { form2.Hvo, form3.Hvo, form4.Hvo }));

				m_actionHandler.BeginUndoTask("Undo doing stuff", "Redo doing stuff");
				form2.LexemeFormOA.Form.SetVernacularDefaultWritingSystem("other");
				form2.SensesOS[0].Gloss.SetAnalysisDefaultWritingSystem("other");
				m_actionHandler.EndUndoTask();

				Assert.That(searchEngine.Search(new[] { new SearchField(LexEntryTags.kflidLexemeForm, Cache.TsStrFactory.MakeString("fo", Cache.DefaultVernWs)) }),
					Is.EquivalentTo(new[] { form3.Hvo, form4.Hvo }));
				Assert.That(searchEngine.Search(new[] { new SearchField(LexSenseTags.kflidGloss, Cache.TsStrFactory.MakeString("gl", Cache.DefaultAnalWs)) }),
					Is.EquivalentTo(new[] { form3.Hvo, form4.Hvo }));
			}
		}