public void Action_RunTwice_ShouldNotDuplicatePictures() { // Setup initial Mongo project has 1 picture and 2 captions var lfProj = _lfProj; var data = new SampleData(); int newMongoPictureCount = data.bsonTestData["senses"][0]["pictures"].AsBsonArray.Count; int newMongoCaptionCount = data.bsonTestData["senses"][0]["pictures"][0]["caption"].AsBsonDocument.Count(); Assert.That(newMongoPictureCount, Is.EqualTo(2)); Assert.That(newMongoCaptionCount, Is.EqualTo(2)); // Initial FDO project has 63 entries, 3 internal pictures, and 1 externally linked picture FdoCache cache = _cache; ILexEntryRepository entryRepo = _servLoc.GetInstance <ILexEntryRepository>(); int originalNumOfFdoPictures = entryRepo.AllInstances().Count( e => (e.SensesOS.Count > 0) && (e.SensesOS[0].PicturesOS.Count > 0)); Assert.That(entryRepo.Count, Is.EqualTo(OriginalNumOfFdoEntries)); Assert.That(originalNumOfFdoPictures, Is.EqualTo(3 + 1)); string expectedGuidStrBefore = data.bsonTestData["guid"].AsString; Guid expectedGuidBefore = Guid.Parse(expectedGuidStrBefore); var entryBefore = entryRepo.GetObject(expectedGuidBefore); Assert.That(entryBefore.SensesOS.Count, Is.GreaterThan(0)); Assert.That(entryBefore.SensesOS.First().PicturesOS.Count, Is.EqualTo(1)); // Exercise running Action twice data.bsonTestData["authorInfo"]["modifiedDate"] = DateTime.UtcNow; _conn.UpdateMockLfLexEntry(data.bsonTestData); sutMongoToFdo.Run(lfProj); data.bsonTestData["authorInfo"]["modifiedDate"] = DateTime.UtcNow; _conn.UpdateMockLfLexEntry(data.bsonTestData); sutMongoToFdo.Run(lfProj); string expectedGuidStr = data.bsonTestData["guid"].AsString; Guid expectedGuid = Guid.Parse(expectedGuidStr); var entry = entryRepo.GetObject(expectedGuid); Assert.IsNotNull(entry); Assert.That(entry.Guid, Is.EqualTo(expectedGuid)); Assert.That(entry.SensesOS.Count, Is.GreaterThan(0)); Assert.That(entry.SensesOS.First().PicturesOS.Count, Is.EqualTo(2)); }
public override ITsString get_StringProp(int hvo, int tag) { if (tag == m_headwordFlid) { int hn; if (m_homographNumbers.TryGetValue(hvo, out hn)) { var entry = m_entryRepo.GetObject(hvo); return(StringServices.HeadWordForWsAndHn(entry, Cache.DefaultVernWs, hn)); } // In case it's one we somehow don't know about, we'll let the base method try to get the real HN. } else if (tag == m_senseOutlineFlid) { var sense = m_senseRepo.GetObject(hvo); return(GetSenseNumberTss(sense)); } return(base.get_StringProp(hvo, tag)); }