コード例 #1
0
        private void AddRelation()
        {
            LexRelationCollection synonyms =
                _source.GetOrCreateProperty <LexRelationCollection>("synonyms");
            LexRelation r = new LexRelation("synonyms", _target.GetOrCreateId(true), _source);

            synonyms.Relations.Add(r);
        }
コード例 #2
0
ファイル: LexEntryTests.cs プロジェクト: smitcham/libpalaso
        public void LexEntryPropertiesInUse_HasMultipleProperties_ReturnsProperties()
        {
            var entry = new LexEntry();

            entry.GetOrCreateProperty <MultiText>("Prop1");
            entry.GetOrCreateProperty <MultiText>("Prop2");
            Assert.That(entry.PropertiesInUse, Contains.Item("Prop1"));
            Assert.That(entry.PropertiesInUse, Contains.Item("Prop2"));
            Assert.That(entry.PropertiesInUse.Count(), Is.EqualTo(2));
        }
コード例 #3
0
ファイル: LexEntryTests.cs プロジェクト: smitcham/libpalaso
        public void LexEntryPropertiesInUse_EntryandMultipleSensesAndExampleSentencesHaveMultipleProperties_ReturnsAllProperties()
        {
            var ex1 = new LexExampleSentence();

            ex1.GetOrCreateProperty <MultiText>("Ex1Prop1");
            ex1.GetOrCreateProperty <MultiText>("Ex1Prop2");

            var ex2 = new LexExampleSentence();

            ex2.GetOrCreateProperty <MultiText>("Ex2Prop1");
            ex2.GetOrCreateProperty <MultiText>("Ex2Prop2");

            var ex3 = new LexExampleSentence();

            ex3.GetOrCreateProperty <MultiText>("Ex3Prop1");
            ex3.GetOrCreateProperty <MultiText>("Ex3Prop2");

            var lexSense1 = new LexSense();

            lexSense1.GetOrCreateProperty <MultiText>("Se1Prop1");
            lexSense1.GetOrCreateProperty <MultiText>("Se1Prop2");

            var lexSense2 = new LexSense();

            lexSense2.GetOrCreateProperty <MultiText>("Se2Prop1");
            lexSense2.GetOrCreateProperty <MultiText>("Se2Prop2");

            var entry = new LexEntry();

            entry.GetOrCreateProperty <MultiText>("Prop1");
            entry.GetOrCreateProperty <MultiText>("Prop2");

            entry.Senses.Add(lexSense1);
            entry.Senses.Add(lexSense2);
            lexSense1.ExampleSentences.Add(ex1);
            lexSense1.ExampleSentences.Add(ex2);
            lexSense2.ExampleSentences.Add(ex3);

            Assert.That(entry.PropertiesInUse, Contains.Item("Ex1Prop1"));
            Assert.That(entry.PropertiesInUse, Contains.Item("Ex1Prop2"));
            Assert.That(entry.PropertiesInUse, Contains.Item("Ex2Prop1"));
            Assert.That(entry.PropertiesInUse, Contains.Item("Ex2Prop2"));
            Assert.That(entry.PropertiesInUse, Contains.Item("Ex3Prop1"));
            Assert.That(entry.PropertiesInUse, Contains.Item("Ex3Prop2"));
            Assert.That(entry.PropertiesInUse, Contains.Item("Se1Prop1"));
            Assert.That(entry.PropertiesInUse, Contains.Item("Se1Prop2"));
            Assert.That(entry.PropertiesInUse, Contains.Item("Se2Prop1"));
            Assert.That(entry.PropertiesInUse, Contains.Item("Se2Prop2"));
            Assert.That(entry.PropertiesInUse, Contains.Item("Prop1"));
            Assert.That(entry.PropertiesInUse, Contains.Item("Prop2"));
            Assert.That(entry.PropertiesInUse.Count(), Is.EqualTo(18));
        }
コード例 #4
0
        public void HiddenFields_AreNotOutput()
        {
            using (var environment = new EnvironmentForTest())
            {
                LexEntry e1 = environment.Repo.CreateItem();
                e1.LexicalForm[EnvironmentForTest.Green] = "sunset";
                e1.GetOrCreateProperty <MultiText>("color").SetAlternative(environment.WritingSystemIds[0], EnvironmentForTest.Red);
                environment.Repo.SaveItem(e1);

                var color = new Field(
                    "color",
                    "LexEntry",
                    environment.WritingSystemIds,
                    Field.MultiplicityType.ZeroOr1,
                    "MultiText"
                    );
                color.DisplayName = "color";
                environment.Template.Add(color);

                environment.DoExport();
                environment.AssertHasAtLeastOneMatch("lift/entry[@id='" + e1.Id + "']/field[@type='" + "color" + "']");

                //now make it invisible and it should disappear
                environment.Template.GetField("color").Enabled = false;

                environment.DoExport();
                environment.AssertNoMatchForXPath("lift/entry[@id='" + e1.Id + "']/field");
            }
        }
コード例 #5
0
        public void LexEntryCustomFieldHasNoWritingSystems()
        {
            var entry = new LexEntry();

            entry.GetOrCreateProperty <MultiText>("customField");
            Assert.AreEqual(true, _missingCustomFieldFilter.FilteringPredicate(entry));
        }
コード例 #6
0
        public void CustomFieldWritingSystemNoVernacular()
        {
            var entry  = new LexEntry();
            var custom = entry.GetOrCreateProperty <MultiText>("customField");

            custom["analysis"] = "filler";
            Assert.AreEqual(true, _missingCustomFieldFilter.FilteringPredicate(entry));
        }
コード例 #7
0
        public void LexEntryCustomFieldHasVernacularWritingSystem()
        {
            var entry  = new LexEntry();
            var custom = entry.GetOrCreateProperty <MultiText>("customField");

            custom["vernacular"] = "filler";

            Assert.AreEqual(false, _missingCustomFieldFilter.FilteringPredicate(entry));
        }
コード例 #8
0
ファイル: LexEntryTests.cs プロジェクト: smitcham/libpalaso
        public void GetHeadword_CitationFormLacksAlternative_GetsFormFromLexemeForm()
        {
            LexEntry entry = new LexEntry();

            entry.LexicalForm.SetAlternative("a", "apple");
            MultiText citation =
                entry.GetOrCreateProperty <MultiText>(LexEntry.WellKnownProperties.Citation);

            citation.SetAlternative("b", "bater");
            Assert.AreEqual("apple", entry.GetHeadWordForm("a"));
        }
コード例 #9
0
        public void TwoEntryCrossRefferences()
        {
            var targetOne = _repo.CreateItem();

            targetOne.LexicalForm.SetAlternative("qaa-x-qaa", "targetOne");
            var targetTwo = _repo.CreateItem();

            targetTwo.LexicalForm.SetAlternative("qaa-x-qaa", "targetTwo");

            var crossRefs = _entry.GetOrCreateProperty <LexRelationCollection>(LexEntry.WellKnownProperties.CrossReference);

            crossRefs.Relations.Add(new LexRelation(LexEntry.WellKnownProperties.CrossReference, targetOne.Id, _entry));
            crossRefs.Relations.Add(new LexRelation(LexEntry.WellKnownProperties.CrossReference, targetTwo.Id, _entry));

            // var dummy =GetXhtmlContents(new List<LexEntry>(new LexEntry[] {_entry}));

            //AssertBodyHas("*//span[@class='crossrefs']/span[@class='crossref-type' and text()='cf']");
            AssertBodyHas("*//span[@class='crossrefs']/span[@class='crossref-targets' and count(span[@class='xitem']) = 2]");
            AssertBodyHas("*//span[@class='xitem']/span[@class='crossref' and text()='targetOne']");
            AssertBodyHas("*//span[@class='xitem']/span[@class='crossref' and text()='targetTwo']");
        }
コード例 #10
0
        public void FilteringPredicate_HasRequiredButNotEmpty_IsChosen()
        {
            var entry  = new LexEntry();
            var custom = entry.GetOrCreateProperty <MultiText>("customField");

            custom["en"] = "hello";

            var field = new Field("customField", "LexEntry", new[] { "en", "fr" });
            var hasEnglishButNotFrenchFilter = new MissingFieldQuery(field, new string[] { "fr" }, new string[] { "en" });

            Assert.IsTrue(hasEnglishButNotFrenchFilter.FilteringPredicate(entry));
        }
コード例 #11
0
ファイル: LexEntryTests.cs プロジェクト: smitcham/libpalaso
        public void GetHeadword_CitationFormHasAlternative_CorrectForm()
        {
            LexEntry entry = new LexEntry();

            entry.LexicalForm.SetAlternative("a", "apple");
            MultiText citation =
                entry.GetOrCreateProperty <MultiText>(LexEntry.WellKnownProperties.Citation);

            citation.SetAlternative("b", "barter");
            citation.SetAlternative("a", "applishus");
            Assert.AreEqual("applishus", entry.GetHeadWordForm("a"));
            Assert.AreEqual("barter", entry.GetHeadWordForm("b"));
            Assert.AreEqual(string.Empty, entry.GetHeadWordForm("donthave"));
        }
コード例 #12
0
        public void MergeInRelation_RelationHasEmbeddedTraits_RelationGetsEmbeddedXmlForLaterRoundTrip()
        {
            LexEntry e   = MakeSimpleEntry();
            var      xml = @"<relation type='component-lexeme' ref='bodzi_d333f64f-d388-431f-bb2b-7dd9b7f3fe3c'>
							<trait name='complex-form-type' value='Composto'></trait>
							<trait name='is-primary' value='true'/>
						</relation>"                        ;

            _builder.MergeInRelation(e, "component-lexeme", "someId", xml);

            LexRelationCollection collection =
                e.GetOrCreateProperty <LexRelationCollection>("component-lexeme");

            Assert.AreEqual(2, collection.Relations[0].EmbeddedXmlElements.Count);
        }
コード例 #13
0
ファイル: LexEntryTests.cs プロジェクト: bbriggs/wesay
		public void GetHeadword_CitationFormLacksAlternative_GetsFormFromLexemeForm()
		{
			LexEntry entry = new LexEntry();
			entry.LexicalForm.SetAlternative("a", "apple");
			MultiText citation =
					entry.GetOrCreateProperty<MultiText>(LexEntry.WellKnownProperties.Citation);
			citation.SetAlternative("b", "bater");
			Assert.AreEqual("apple", entry.GetHeadWordForm("a"));
		}
コード例 #14
0
ファイル: LexEntryTests.cs プロジェクト: bbriggs/wesay
		public void GetHeadword_CitationFormHasAlternative_CorrectForm()
		{
			LexEntry entry = new LexEntry();
			entry.LexicalForm.SetAlternative("a", "apple");
			MultiText citation =
					entry.GetOrCreateProperty<MultiText>(LexEntry.WellKnownProperties.Citation);
			citation.SetAlternative("b", "barter");
			citation.SetAlternative("a", "applishus");
			Assert.AreEqual("applishus", entry.GetHeadWordForm("a"));
			Assert.AreEqual("barter", entry.GetHeadWordForm("b"));
			Assert.AreEqual(string.Empty, entry.GetHeadWordForm("donthave"));
		}