public void GetCustomFieldsForThisCmObject_ShouldGetCustomFieldSettings() { // Setup var lfProject = _lfProj; var cache = _cache; Guid entryGuid = Guid.Parse(TestEntryGuidStr); var entry = _servLoc.GetInstance <ILexEntryRepository>().GetObject(entryGuid); Assert.That(entry, Is.Not.Null); ConvertFdoToMongoCustomField converter = new ConvertFdoToMongoCustomField(cache, _servLoc, new TestLogger(TestContext.CurrentContext.Test.Name)); // Exercise var customDataDocument = converter.GetCustomFieldsForThisCmObject(entry, "entry", _listConverters); // Verify var expectedCustomFieldNames = new List <string> { "customField_entry_Cust_Date", "customField_entry_Cust_MultiPara", "customField_entry_Cust_Number", "customField_entry_Cust_Single_Line", "customField_entry_Cust_Single_Line_All", "customField_entry_Cust_Single_ListRef" }; CollectionAssert.AreEquivalent(expectedCustomFieldNames, customDataDocument[0].AsBsonDocument.Names); }
protected BsonDocument GetCustomFieldValues(FdoCache cache, ICmObject obj, string objectType = "entry") { // The objectType parameter is used in the names of the custom fields (and nowhere else). var convertCustomField = new ConvertFdoToMongoCustomField(cache, _servLoc, new LfMerge.Core.Logging.NullLogger()); return(convertCustomField.GetCustomFieldsForThisCmObject(obj, objectType, _listConverters)); }
public void GetCustomFieldForThisCmObject_ShouldGetSingleLineAll() { // Setup var lfProject = _lfProj; var converter = new ConvertFdoToMongoCustomField(_cache, _servLoc, new TestLogger(TestContext.CurrentContext.Test.Name)); Guid entryGuid = Guid.Parse(TestEntryGuidStr); var entry = _servLoc.GetInstance <ILexEntryRepository>().GetObject(entryGuid) as ILexEntry; Assert.That(entry, Is.Not.Null); // Exercise BsonDocument customDataDocument = converter.GetCustomFieldsForThisCmObject(entry, "entry", _listConverters); // Verify English and french values Assert.That(customDataDocument[0]["customField_entry_Cust_Single_Line_All"].AsBsonDocument.GetElement(0).Value["value"].ToString(), Is.EqualTo("Some custom text")); Assert.That(customDataDocument[0]["customField_entry_Cust_Single_Line_All"].AsBsonDocument.GetElement(1).Value["value"].ToString(), Is.EqualTo("French custom text")); }
public void GetCustomFieldForThisCmObject_ShouldGetMultiListRef() { // Setup var lfProject = _lfProj; var cache = _cache; var converter = new ConvertFdoToMongoCustomField(cache, _servLoc, new TestLogger(TestContext.CurrentContext.Test.Name)); Guid entryGuid = Guid.Parse(TestEntryGuidStr); var entry = _servLoc.GetInstance <ILexEntryRepository>().GetObject(entryGuid); Assert.That(entry, Is.Not.Null); // Exercise ILexSense[] senses = entry.SensesOS.ToArray(); BsonDocument customDataDocument = converter.GetCustomFieldsForThisCmObject(senses[0], "senses", _listConverters); // Verify. (Note, in the fwdata file, the custom item labels are in reverse order) Assert.That(customDataDocument[0].AsBsonDocument["customField_senses_Cust_Multi_ListRef"]["values"][1].ToString(), Is.EqualTo("fci")); Assert.That(customDataDocument[0].AsBsonDocument["customField_senses_Cust_Multi_ListRef"]["values"][0].ToString(), Is.EqualTo("sci")); }