public void Setup() { WeSayProjectTestHelper.InitializeForTests(); _tempFolder = new TemporaryFolder(); _filePath = _tempFolder.GetTemporaryFile(); _lexEntryRepository = new LexEntryRepository(_filePath); _target = CreateEntry("one", "single item"); _source = CreateEntry("single", "one item"); CreateEntry("verde", "green"); CreateEntry("amarelho", "yellow"); CreateEntry("azul", "blue"); _synonymsRelationField = new Field("synonyms", "LexEntry", new string[] { WritingSystemsIdsForTests.OtherIdForTest }, Field.MultiplicityType.ZeroOrMore, "RelationToOneEntry"); _synonymsRelationType = new LexRelationType("synonyms", LexRelationType.Multiplicities.Many, LexRelationType.TargetTypes.Sense); _singleSynonymRelationField = new Field("synonym", "LexEntry", new string[] { WritingSystemsIdsForTests.OtherIdForTest }, Field.MultiplicityType.ZeroOr1, "RelationToOneEntry"); _singleSynonymRelationType = new LexRelationType("synonym", LexRelationType.Multiplicities.One, LexRelationType.TargetTypes.Sense); }
public void Setup() { WeSayWordsProject.InitializeForTests(); _tempFolder = new TemporaryFolder(); _filePath = _tempFolder.GetTemporaryFile(); _lexEntryRepository = new LexEntryRepository(_filePath); _target = CreateEntry("one", "single item"); _source = CreateEntry("single", "one item"); CreateEntry("verde", "green"); CreateEntry("amarelho", "yellow"); CreateEntry("azul", "blue"); _synonymsRelationField = new Field("synonyms", "LexEntry", new string[] {"vernacular"}, Field.MultiplicityType.ZeroOrMore, "RelationToOneEntry"); _synonymsRelationType = new LexRelationType("synonyms", LexRelationType.Multiplicities.Many, LexRelationType.TargetTypes.Sense); _singleSynonymRelationField = new Field("synonym", "LexEntry", new string[] {"vernacular"}, Field.MultiplicityType.ZeroOr1, "RelationToOneEntry"); _singleSynonymRelationType = new LexRelationType("synonym", LexRelationType.Multiplicities.One, LexRelationType.TargetTypes.Sense); }
private Control MakeRelationWidget(PalasoDataObject target, LexRelationType type, Field field) { return(RelationController.CreateWidget(target, type, field, _lexEntryRepository, _detailList.OnBinding_ChangeOfWhichItemIsInFocus)); }
public void Construct_TargetIdNull_TargetIdIsEmptyString() { LexSense sense = new LexSense(); LexRelationType synonymRelationType = new LexRelationType("synonym", LexRelationType.Multiplicities .Many, LexRelationType.TargetTypes. Sense); LexRelation relation = new LexRelation(synonymRelationType.ID, null, sense); Assert.AreEqual(null, relation.GetTarget(_lexEntryRepository)); Assert.AreEqual(string.Empty, relation.Key); }
public void Construct_TargetIdNull_TargetIdIsEmptyString() { LexSense sense = new LexSense(); LexRelationType synonymRelationType = new LexRelationType("synonym", LexRelationType.Multiplicities .Many, LexRelationType.TargetTypes. Sense); LexRelation relation = new LexRelation(synonymRelationType.ID, null, sense); Assert.AreEqual(string.Empty, relation.Key); }
private RelationController(PalasoDataObject relationParent, LexRelationType relationType, Field field, LexEntryRepository lexEntryRepository, EventHandler <CurrentItemEventArgs> focus) { _relationParent = relationParent; _relationType = relationType; _field = field; _lexEntryRepository = lexEntryRepository; _focusDelegate = focus; MakeControl(); }
public void TargetId_SetNull_GetStringEmpty() { LexSense sense = new LexSense(); LexRelationType synonymRelationType = new LexRelationType("synonym", LexRelationType.Multiplicities .Many, LexRelationType.TargetTypes. Sense); LexRelation relation = new LexRelation(synonymRelationType.ID, "something", sense); relation.Key = null; Assert.AreEqual(null, relation.GetTarget(_lexEntryRepository)); Assert.AreEqual(string.Empty, relation.Key); }
public void TargetId_SetNull_GetStringEmpty() { LexSense sense = new LexSense(); LexRelationType synonymRelationType = new LexRelationType("synonym", LexRelationType.Multiplicities .Many, LexRelationType.TargetTypes. Sense); LexRelation relation = new LexRelation(synonymRelationType.ID, "something", sense); relation.Key = null; Assert.AreEqual(string.Empty, relation.Key); }
public static Control CreateWidget(PalasoDataObject relationParent, LexRelationType relationType, Field field, LexEntryRepository lexEntryRepository, EventHandler <CurrentItemEventArgs> focus) { if (field.WritingSystemIds.Count == 0) { throw new ConfigurationException("The field {0} has no input systems enabled.", field.FieldName); } var controller = new RelationController(relationParent, relationType, field, lexEntryRepository, focus); return(controller.Control); }
public void SenseWithSynonymRelations() { LexSense sense = new LexSense(); LexRelationType synonymRelationType = new LexRelationType("synonym", LexRelationType.Multiplicities .Many, LexRelationType.TargetTypes. Sense); LexRelationType antonymRelationType = new LexRelationType("antonym", LexRelationType.Multiplicities .Many, LexRelationType.TargetTypes. Sense); LexRelationCollection relations = new LexRelationCollection(); sense.Properties.Add(new KeyValuePair<string, object>("relations", relations)); relations.Relations.Add(new LexRelation(synonymRelationType.ID, "one", sense)); relations.Relations.Add(new LexRelation(synonymRelationType.ID, "two", sense)); relations.Relations.Add(new LexRelation(antonymRelationType.ID, "bee", sense)); _exporter.Add(sense); CheckAnswer(GetSenseElement(sense) + "<relation type=\"synonym\" ref=\"one\" /><relation type=\"synonym\" ref=\"two\" /><relation type=\"antonym\" ref=\"bee\" /></sense>"); }
private int AddOneCustomField(PalasoDataObject target, Field customField, int insertAtRow, int rowCount) { IReportEmptiness data = target.GetProperty <IReportEmptiness>(customField.FieldName); if (!customField.GetDoShow(data, ShowNormallyHiddenFields)) { return(rowCount); } Control box; switch (customField.DataTypeName) { case "Picture": box = MakePictureWidget(target, customField, _detailList); if (box == null) { return(rowCount); // other code does the user notification } break; case "Flag": box = MakeCheckBoxWidget(target, customField); break; case "Option": box = MakeOptionWidget(target, customField); break; case "OptionCollection": box = MakeOptionCollectionWidget(target, customField); break; case "MultiText": box = MakeBoundControl( target.GetOrCreateProperty <MultiText>(customField.FieldName), customField); break; default: LexRelationType lexRelType = GetRelationType(customField.DataTypeName); if (lexRelType != null) { box = MakeRelationWidget(target, lexRelType, customField); } else { throw new ApplicationException( string.Format("WeSay doesn't understand how to layout a {0}", customField.DataTypeName)); } break; } string label = StringCatalog.Get(customField.DisplayName); //for checkboxes, the label is part of the control if (customField.DataTypeName == "Flag") { label = string.Empty; } Control c = DetailList.AddWidgetRow(StringCatalog.Get(label), false, box, insertAtRow, false); DetailList.GetRow(c); ++rowCount; return(rowCount); }
public void SenseWithRelationWithEmbeddedXml() { using (var session = new LiftExportAsFragmentTestSession()) { var sense = new LexSense(); var synonymRelationType = new LexRelationType( "synonym", LexRelationType.Multiplicities.Many, LexRelationType.TargetTypes.Sense ); var relations = new LexRelationCollection(); sense.Properties.Add(new KeyValuePair<string, IPalasoDataObjectProperty>("relations", relations)); var lexRelation = new LexRelation(synonymRelationType.ID, "one", sense); lexRelation.EmbeddedXmlElements.Add("<trait name='x' value='X'/>"); lexRelation.EmbeddedXmlElements.Add("<field id='z'><text>hello</text></field>"); relations.Relations.Add(lexRelation); session.LiftWriter.Add(sense); session.LiftWriter.End(); AssertThatXmlIn.String(session.StringBuilder.ToString()).HasSpecifiedNumberOfMatchesForXpath("//sense/relation/trait",1); AssertThatXmlIn.String(session.StringBuilder.ToString()).HasSpecifiedNumberOfMatchesForXpath("//sense/relation/field", 1); } }
public void SenseWithSynonymRelations() { using (var session = new LiftExportAsFragmentTestSession()) { var sense = new LexSense(); var synonymRelationType = new LexRelationType( "synonym", LexRelationType.Multiplicities.Many, LexRelationType.TargetTypes.Sense ); var antonymRelationType = new LexRelationType( "antonym", LexRelationType.Multiplicities.Many, LexRelationType.TargetTypes.Sense ); var relations = new LexRelationCollection(); sense.Properties.Add(new KeyValuePair<string, IPalasoDataObjectProperty>("relations", relations)); relations.Relations.Add(new LexRelation(synonymRelationType.ID, "one", sense)); relations.Relations.Add(new LexRelation(synonymRelationType.ID, "two", sense)); relations.Relations.Add(new LexRelation(antonymRelationType.ID, "bee", sense)); session.LiftWriter.Add(sense); string result = session.OutputString(); AssertThatXmlIn.String(result).HasAtLeastOneMatchForXpath( "/sense/relation[@type='synonym' and @ref='one']" ); AssertThatXmlIn.String(result).HasAtLeastOneMatchForXpath( "/sense/relation[@type='synonym' and @ref='two']" ); AssertThatXmlIn.String(result).HasAtLeastOneMatchForXpath( "/sense/relation[@type='antonym' and @ref='bee']" ); } }