public void NewEntryGetsId()
		{
			Extensible extensibleInfo = new Extensible();
			extensibleInfo.Id = "foo";
			LexEntry e = _builder.GetOrMakeEntry(extensibleInfo, 0);
			Assert.AreEqual(extensibleInfo.Id, e.Id);
			_builder.FinishEntry(e);
			Assert.AreEqual(1, _dataMapper.CountAllItems());
		}
		public void NewEntry_HasSemanticDomainWeDontKnowAbout_AddedAnyways()
		{
			Extensible extensibleInfo = new Extensible();
			LexEntry e = _builder.GetOrMakeEntry(extensibleInfo, 0);
			LexSense s = _builder.GetOrMakeSense(e, new Extensible(), string.Empty);

			var t = new Trait("semantic-domain-ddp4",
								"9.9.9.9.9.9 Computer Gadgets" );
			_builder.MergeInTrait(s, t);
			_builder.FinishEntry(e);
			var property = e.Senses[0].GetProperty<OptionRefCollection>(LexSense.WellKnownProperties.SemanticDomainDdp4);
			Assert.AreEqual("9.9.9.9.9.9 Computer Gadgets", property.KeyAtIndex(0));
		}
		public void NewEntry_HasSemanticDomainWithTextualLabel_CorrectlyAddsSemanticDomain()
		{
			Extensible extensibleInfo = new Extensible();
			LexEntry e = _builder.GetOrMakeEntry(extensibleInfo, 0);
			LexSense s = _builder.GetOrMakeSense(e, new Extensible(), string.Empty);

			var t = new Trait("semantic-domain-ddp4", //the name has migrated up to this already
								"4.2.7");
			_builder.MergeInTrait(s, t);
			_builder.FinishEntry(e);
			var property = e.Senses[0].GetProperty<OptionRefCollection>(LexSense.WellKnownProperties.SemanticDomainDdp4);
			Assert.AreEqual("4.2.7 Play, fun", property.KeyAtIndex(0));
		}
Exemplo n.º 4
0
		///<summary>
		/// Constructor.
		///</summary>
		public LiftSense(Extensible info, Guid guid, LiftObject owner)
		{
			Subsenses = new List<LiftSense>();
			Illustrations = new List<LiftUrlRef>();
			Reversals = new List<LiftReversal>();
			Examples = new List<LiftExample>();
			Notes = new List<LiftNote>();
			Relations = new List<LiftRelation>();
			Id = info.Id;
			Guid = guid;
			DateCreated = info.CreationTime;
			DateModified = info.ModificationTime;
			Owner = owner;
		}
Exemplo n.º 5
0
		///<summary>
		/// Constructor.
		///</summary>
		public LiftEntry(Extensible info, Guid guid, int order)
		{
			Etymologies = new List<LiftEtymology>();
			Relations = new List<LiftRelation>();
			Notes = new List<LiftNote>();
			Senses = new List<LiftSense>();
			Variants = new List<LiftVariant>();
			Pronunciations = new List<LiftPhonetic>();
			Id = info.Id;
			Guid = guid;
			DateCreated = info.CreationTime;
			DateModified = info.ModificationTime;
			DateDeleted = DateTime.MinValue;
			Order = order;
		}
		private static Extensible AddDates(Extensible extensibleInfo)
		{
			extensibleInfo.CreationTime = Extensible.ParseDateTimeCorrectly("2003-08-07T08:42:42Z");
			extensibleInfo.ModificationTime =
					Extensible.ParseDateTimeCorrectly("2005-01-01T01:11:11+8:00");
			return extensibleInfo;
		}
		public void EntryWithChildren()
		{
			Extensible extensibleInfo = new Extensible();
			LexEntry e = MakeSimpleEntry();
			LexSense s = _builder.GetOrMakeSense(e, extensibleInfo, string.Empty);

			LexExampleSentence ex = _builder.GetOrMakeExample(s, new Extensible());
			ex.Sentence["foo"] = "this is a sentence";
			ex.Translation["aa"] = "aaaa";
			_builder.FinishEntry(e);
			CheckCompleteEntry(e);

			RepositoryId[] entries = _dataMapper.GetAllItems();
			Assert.AreEqual(1, entries.Length);

			//now check it again, from the list
			CheckCompleteEntry(_dataMapper.GetItem(entries[0]));
		}
		public void GetOrMakeEntry_ReturnedLexEntryIsDirty()
		{
			Extensible extensibleInfo = new Extensible();
			LexEntry entry = _builder.GetOrMakeEntry(extensibleInfo, 0);
			Assert.IsTrue(entry.IsDirty);
		}
		public void SenseGetsPictureNoCaption()
		{
			Extensible extensibleInfo = new Extensible();
			LexEntry e = MakeSimpleEntry();
			LexSense s = _builder.GetOrMakeSense(e, extensibleInfo, string.Empty);

			_builder.MergeInPicture(s, "testPicture.png", null);
			PictureRef pict = s.GetProperty<PictureRef>("Picture");
			Assert.AreEqual("testPicture.png", pict.Value);
			Assert.IsNull(pict.Caption);
		}
		public void NewEntryTakesGivenDates()
		{
			Extensible extensibleInfo = new Extensible();
			extensibleInfo = AddDates(extensibleInfo);

			LexEntry e = _builder.GetOrMakeEntry(extensibleInfo, 0);
			Assert.AreEqual(extensibleInfo.CreationTime, e.CreationTime);
			Assert.AreEqual(extensibleInfo.ModificationTime, e.ModificationTime);
		}
		public void NewEntryWithTextIdIgnoresIt()
		{
			Extensible extensibleInfo = new Extensible();
			extensibleInfo.Id = "hello";
			LexEntry e = _builder.GetOrMakeEntry(extensibleInfo, 0);
			//no attempt is made to use that id
			Assert.IsNotNull(e.Guid);
			Assert.AreNotSame(Guid.Empty, e.Guid);
		}
		public void NewEntry_NoGlossNoDef_GetNeitherInTheSense()
		{
			Extensible extensibleInfo = new Extensible();
			LexEntry e = _builder.GetOrMakeEntry(extensibleInfo, 0);
			LexSense s = _builder.GetOrMakeSense(e, new Extensible(), string.Empty);
			_builder.FinishEntry(e);
			Assert.AreEqual(0,e.Senses[0].Gloss.Count);
			Assert.AreEqual(0, e.Senses[0].Definition.Count);
		}
		public void NewEntry_YesDefYesGloss_BothUnchanged()
		{
			Extensible extensibleInfo = new Extensible();
			LexEntry e = _builder.GetOrMakeEntry(extensibleInfo, 0);
			LexSense s = _builder.GetOrMakeSense(e, new Extensible(), string.Empty);
			_builder.MergeInGloss(s, new LiftMultiText("x", "x gloss"));
			_builder.MergeInDefinition(s, new LiftMultiText("x", "x def"));
			_builder.FinishEntry(e);
			Assert.AreEqual("x gloss", e.Senses[0].Gloss.GetExactAlternative("x"));
			Assert.AreEqual("x def", e.Senses[0].Definition.GetExactAlternative("x"));
		}
		public void NewEntry_HasDefGlossHasAnotherWSAlternative_CopiedToDefintion()
		{
		  //  _builder.AfterEntryRead += _builder.ApplyWeSayPolicyToParsedEntry;

			Extensible extensibleInfo = new Extensible();
			LexEntry e = _builder.GetOrMakeEntry(extensibleInfo, 0);
			LexSense s = _builder.GetOrMakeSense(e, new Extensible(), string.Empty);
			_builder.MergeInDefinition(s, new LiftMultiText("x", "x def"));
			_builder.MergeInGloss(s, new LiftMultiText("x", "x meaning"));
			_builder.MergeInGloss(s, new LiftMultiText("y", "y meaning"));
			_builder.FinishEntry(e);
			Assert.AreEqual("x meaning", e.Senses[0].Gloss.GetExactAlternative("x"));
			Assert.AreEqual("x def", e.Senses[0].Definition.GetExactAlternative("x"));
			Assert.AreEqual("y meaning", e.Senses[0].Definition.GetExactAlternative("y"));
		}
		public void NewEntry_OldLiteralMeaning_GetsMoved()
		{
		   // _builder.AfterEntryRead += _builder.ApplyWeSayPolicyToParsedEntry;

			Extensible extensibleInfo = new Extensible();
			LexEntry e = _builder.GetOrMakeEntry(extensibleInfo, 0);
			LexSense s = _builder.GetOrMakeSense(e, new Extensible(), string.Empty);
			LiftMultiText t = new LiftMultiText("en", "test");
			_builder.MergeInField(s, "LiteralMeaning", default(DateTime), default(DateTime), t, null);
			_builder.FinishEntry(e);
			Assert.IsNull(e.Senses[0].GetProperty<MultiText>("LiteralMeaning"));
			Assert.IsNotNull(e.GetProperty<MultiText>(LexEntry.WellKnownProperties.LiteralMeaning));
			Assert.AreEqual("test", e.GetProperty<MultiText>(LexEntry.WellKnownProperties.LiteralMeaning).GetExactAlternative("en"));
		}
		private static Extensible CreateFullextensibleInfo(Guid g)
		{
			Extensible extensibleInfo = new Extensible();
			extensibleInfo.Guid = g;
			extensibleInfo = AddDates(extensibleInfo);
			return extensibleInfo;
		}
		private LexEntry MakeSimpleEntry()
		{
			Extensible extensibleInfo = new Extensible();
			return _builder.GetOrMakeEntry(extensibleInfo, 0);
		}
		public void SenseGetsExample()
		{
			LexSense sense = new LexSense();
			Extensible x = new Extensible();
			LexExampleSentence ex = _builder.GetOrMakeExample(sense, x);
			Assert.IsNotNull(ex);
			_builder.MergeInExampleForm(ex, MakeBasicLiftMultiText());
			Assert.AreEqual(2, ex.Sentence.Forms.Length);
			Assert.AreEqual("dos", ex.Sentence["ws-two"]);
		}
		public void SenseGetsPictureWithCaption()
		{
			Extensible extensibleInfo = new Extensible();
			LexEntry e = MakeSimpleEntry();
			LexSense s = _builder.GetOrMakeSense(e, extensibleInfo, string.Empty);

			LiftMultiText caption = new LiftMultiText();
			caption["aa"] = new LiftString("acaption");
			_builder.MergeInPicture(s, "testPicture.png", caption);
			PictureRef pict = s.GetProperty<PictureRef>("Picture");
			Assert.AreEqual("testPicture.png", pict.Value);
			Assert.AreEqual("acaption", pict.Caption["aa"]);
		}
		public void SenseGetsId()
		{
			Extensible extensibleInfo = new Extensible();
			extensibleInfo.Id = "foo";
			LexSense s = _builder.GetOrMakeSense(new LexEntry(), extensibleInfo, string.Empty);
			Assert.AreEqual(extensibleInfo.Id, s.Id);
		}
		public void NewEntryGetsDates()
		{
			Extensible extensibleInfo = new Extensible();
			extensibleInfo.CreationTime = DateTime.Parse("2/2/1969  12:15:12").ToUniversalTime();
			extensibleInfo.ModificationTime =
					DateTime.Parse("10/11/1968  12:15:12").ToUniversalTime();
			LexEntry e = _builder.GetOrMakeEntry(extensibleInfo, 0);
			Assert.AreEqual(extensibleInfo.CreationTime, e.CreationTime);
			Assert.AreEqual(extensibleInfo.ModificationTime, e.ModificationTime);
			_builder.FinishEntry(e);
			Assert.AreEqual(1, _dataMapper.CountAllItems());
		}
Exemplo n.º 22
0
		public void Entry_Order()
		{
			Extensible extensibleInfo = new Extensible();
			LexEntry entry4 = _builder.GetOrMakeEntry(extensibleInfo, 4);
			_builder.FinishEntry(entry4);
			LexEntry entry1 = _builder.GetOrMakeEntry(extensibleInfo, 1);
			_builder.FinishEntry(entry1);
			LexEntry entry2 = _builder.GetOrMakeEntry(extensibleInfo, 2);
			_builder.FinishEntry(entry2);
			_liftWriter.Add(entry4, 3);
			_liftWriter.Add(entry1, 1);
			_liftWriter.Add(entry2, 2);

			_liftWriter.End();
			AssertHasAtLeastOneMatch("//entry[@order='1']");
			AssertHasAtLeastOneMatch("//entry[@order='2']");
			AssertHasAtLeastOneMatch("//entry[@order='3']");
		}