Example #1
0
        public void ExampleSentencePropertiesInUse_HasMultipleProperties_ReturnsProperties()
        {
            var ex = new LexExampleSentence();

            ex.GetOrCreateProperty <MultiText>("Prop1");
            ex.GetOrCreateProperty <MultiText>("Prop2");
            Assert.That(ex.PropertiesInUse, Contains.Item("Prop1"));
            Assert.That(ex.PropertiesInUse, Contains.Item("Prop2"));
            Assert.That(ex.PropertiesInUse.Count(), Is.EqualTo(4));
        }
Example #2
0
        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));
        }
Example #3
0
        private void ClearExampleCustom()
        {
            MultiText customFieldInExample =
                _examples.GetOrCreateProperty <MultiText>("customFieldInExample");

            customFieldInExample["th"] = string.Empty;
            _entry.CleanUpAfterEditting();
        }
Example #4
0
        public void LexSensePropertiesInUse_SenseAndMulitipleExampleSentencesHaveMultipleProperties_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 lexSense = new LexSense();

            lexSense.GetOrCreateProperty <MultiText>("Prop1");
            lexSense.GetOrCreateProperty <MultiText>("Prop2");
            lexSense.ExampleSentences.Add(ex1);
            lexSense.ExampleSentences.Add(ex2);
            Assert.That(lexSense.PropertiesInUse, Contains.Item("Ex1Prop1"));
            Assert.That(lexSense.PropertiesInUse, Contains.Item("Ex1Prop2"));
            Assert.That(lexSense.PropertiesInUse, Contains.Item("Ex2Prop1"));
            Assert.That(lexSense.PropertiesInUse, Contains.Item("Ex2Prop2"));
            Assert.That(lexSense.PropertiesInUse, Contains.Item("Prop1"));
            Assert.That(lexSense.PropertiesInUse, Contains.Item("Prop2"));
            Assert.That(lexSense.PropertiesInUse.Count(), Is.EqualTo(10));
        }
Example #5
0
        public void SenseOneExampleCustomWritingSystemWithOneWithoutAnalysis()
        {
            var entry   = CreateEmptyLexEntryWithOneEmptySentence();
            var example = entry.Senses[0].ExampleSentences[0];

            var custom = example.GetOrCreateProperty <MultiText>("customField");

            custom["vernacular"] = "filler";

            example = new LexExampleSentence();
            entry.Senses[0].ExampleSentences.Add(example);
            custom             = example.GetOrCreateProperty <MultiText>("customField");
            custom["analysis"] = "filler";
            Assert.AreEqual(true, _missingCustomFieldFilter.FilteringPredicate(entry));
        }
Example #6
0
		public void Setup()
		{
			_entry = new LexEntry();
			_sense = new LexSense();
			_entry.Senses.Add(_sense);
#if GlossMeaning
			this._sense.Gloss["th"] = "sense";
#else
			_sense.Definition["th"] = "sense";
#endif
			MultiText customFieldInSense =
					_sense.GetOrCreateProperty<MultiText>("customFieldInSense");
			customFieldInSense["th"] = "custom";
			_examples = new LexExampleSentence();
			_sense.ExampleSentences.Add(_examples);
			_examples.Sentence["th"] = "example";
			_examples.Translation["en"] = "translation";
			MultiText customFieldInExample =
					_examples.GetOrCreateProperty<MultiText>("customFieldInExample");
			customFieldInExample["th"] = "custom";
			_entry.EmptyObjectsRemoved += _entry_EmptyObjectsRemoved;
			_entry.PropertyChanged += _entry_PropertyChanged;
			_removed = false;
		}
Example #7
0
        public void Setup()
        {
            _entry = new LexEntry();
            _sense = new LexSense();
            _entry.Senses.Add(_sense);
#if GlossMeaning
            this._sense.Gloss["th"] = "sense";
#else
            _sense.Definition["th"] = "sense";
#endif
            MultiText customFieldInSense =
                _sense.GetOrCreateProperty <MultiText>("customFieldInSense");
            customFieldInSense["th"] = "custom";
            _examples = new LexExampleSentence();
            _sense.ExampleSentences.Add(_examples);
            _examples.Sentence["th"]    = "example";
            _examples.Translation["en"] = "translation";
            MultiText customFieldInExample =
                _examples.GetOrCreateProperty <MultiText>("customFieldInExample");
            customFieldInExample["th"]  = "custom";
            _entry.EmptyObjectsRemoved += _entry_EmptyObjectsRemoved;
            _entry.PropertyChanged     += _entry_PropertyChanged;
            _removed = false;
        }
Example #8
0
		public void EmptyExampleSource_NoAttribute()
		{
			using (var session = new LiftExportAsFragmentTestSession())
			{
				var ex = new LexExampleSentence();
				ex.GetOrCreateProperty<OptionRef>(
					LexExampleSentence.WellKnownProperties.Source
				);
				session.LiftWriter.Add(ex);
				session.LiftWriter.End();
				AssertHasAtLeastOneMatch("example[not(@source)]", session);
			}
		}
Example #9
0
		public void NoteOnExample_OutputAsNote()
		{
			LexExampleSentence example = new LexExampleSentence();
			MultiText m =
					example.GetOrCreateProperty<MultiText>(WeSayDataObject.WellKnownProperties.Note);
			m["zz"] = "orange";
			_exporter.Add(example);
			_exporter.End();
			AssertXPathNotNull("example/note/form[@lang='zz' and text='orange']");
			AssertXPathNotNull("example[not(field)]");
		}
Example #10
0
		public void ExampleSourceAsAttribute()
		{
			LexExampleSentence ex = new LexExampleSentence();
			OptionRef z =
					ex.GetOrCreateProperty<OptionRef>(LexExampleSentence.WellKnownProperties.Source);
			z.Value = "hearsay";

			_exporter.Add(ex);
			_exporter.End();
			AssertXPathNotNull("example[@source='hearsay']");
		}
Example #11
0
		public void EmptyExampleSource_NoAttribute()
		{
			LexExampleSentence ex = new LexExampleSentence();
			ex.GetOrCreateProperty<OptionRef>(LexExampleSentence.WellKnownProperties.Source);
			_exporter.Add(ex);
			_exporter.End();
			AssertXPathNotNull("example[not(@source)]");
		}
Example #12
0
		public void CustomOptionRefOnExample()
		{
			_fieldToOptionListName.Add("flub", "kindsOfFlubs");
			LexExampleSentence example = new LexExampleSentence();
			OptionRef o = example.GetOrCreateProperty<OptionRef>("flub");
			o.Value = "orange";
			_exporter.Add(example);
			_exporter.End();
			Assert.AreEqual("<example><trait name=\"flub\" value=\"orange\" /></example>",
							_stringBuilder.ToString());
		}
Example #13
0
		public void CustomOptionRefCollectionOnExample()
		{
			_fieldToOptionListName.Add("flubs", "colors");
			LexExampleSentence example = new LexExampleSentence();
			OptionRefCollection o = example.GetOrCreateProperty<OptionRefCollection>("flubs");
			o.AddRange(new string[] {"orange", "blue"});
			_exporter.Add(example);
			_exporter.End();
			Assert.AreEqual(
					"<example><trait name=\"flubs\" value=\"orange\" /><trait name=\"flubs\" value=\"blue\" /></example>",
					_stringBuilder.ToString());
		}
Example #14
0
		public void CustomMultiTextOnExample()
		{
			LexExampleSentence example = new LexExampleSentence();
			MultiText m = example.GetOrCreateProperty<MultiText>("flubadub");
			m["zz"] = "orange";
			_exporter.Add(example);
			_exporter.End();
			AssertXPathNotNull("example/field[@type='flubadub']/form[@lang='zz' and text='orange']");
		}
Example #15
0
		public void ExampleSourceAsAttribute()
		{
			using (var session = new LiftExportAsFragmentTestSession())
			{
				LexExampleSentence ex = new LexExampleSentence();
				OptionRef z = ex.GetOrCreateProperty<OptionRef>(
					LexExampleSentence.WellKnownProperties.Source
				);
				z.Value = "hearsay";

				session.LiftWriter.Add(ex);
				session.LiftWriter.End();
				AssertHasAtLeastOneMatch("example[@source='hearsay']", session);
			}
		}
Example #16
0
		public void CustomOptionRefOnExample()
		{
			using (var session = new LiftExportAsFragmentTestSession())
			{
				//_fieldToOptionListName.Add("flub", "kindsOfFlubs");
				var example = new LexExampleSentence();
				var o = example.GetOrCreateProperty<OptionRef>("flub");
				o.Value = "orange";
				session.LiftWriter.Add(example);
				session.LiftWriter.End();
				string expected = CanonicalXml.ToCanonicalStringFragment(
					"<example><trait name=\"flub\" value=\"orange\" /></example>"
				);
				Assert.AreEqual(
					expected,
					session.StringBuilder.ToString()
				);
			}
		}
Example #17
0
		public void CustomMultiTextOnExample()
		{
			using (var session = new LiftExportAsFragmentTestSession())
			{
				var example = new LexExampleSentence();
				var m = example.GetOrCreateProperty<MultiText>("flubadub");
				m["zz"] = "orange";
				session.LiftWriter.Add(example);
				session.LiftWriter.End();
				AssertHasAtLeastOneMatch("example/field[@type='flubadub']/form[@lang='zz' and text='orange']", session);
			}
		}
Example #18
0
		public void NoteOnExample_OutputAsNote()
		{
			using (var session = new LiftExportAsFragmentTestSession())
			{
				LexExampleSentence example = new LexExampleSentence();
				MultiText m =
					example.GetOrCreateProperty<MultiText>(PalasoDataObject.WellKnownProperties.Note);
				m["zz"] = "orange";
				session.LiftWriter.Add(example);
				session.LiftWriter.End();
				AssertHasAtLeastOneMatch("example/note/form[@lang='zz' and text='orange']", session);
				AssertHasAtLeastOneMatch("example[not(field)]", session);
			}
		}