Example #1
0
        public void TestImportCreatesReusesExistingSpeaker()
        {
            string xml = "<document><interlinear-text guid=\"AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA\">" +
                         "<item type=\"title\" lang=\"en\">wordspace</item>" +
                         "<item type=\"title-abbreviation\" lang=\"en\">ws</item>" +
                         "<paragraphs><paragraph><phrases><phrase speaker=\"Jimmy Dorante\" media-file=\"FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF\" guid=\"BBBBBBBB-BBBB-BBBB-BBBB-BBBBBBBBBBBB\" begin-time-offset=\"1\" end-time-offset=\"2\">" +
                         "<item type=\"text\">This is a test with text.</item><word>This</word></phrase></phrases></paragraph></paragraphs>" +
                         "<languages><language lang=\"en\" font=\"latin\" vernacular=\"false\"/></languages>" +
                         "<media-files offset-type=\"milliseconds\"><media guid=\"FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF\" location=\"file:\\\\test.wav\"/></media-files></interlinear-text></document>";

            ICmPerson newPerson = null;

            //Create and add Jimmy to the project.
            NonUndoableUnitOfWorkHelper.Do(Cache.ActionHandlerAccessor,
                                           () => {
                Cache.LanguageProject.PeopleOA = Cache.ServiceLocator.GetInstance <ICmPossibilityListFactory>().Create();
                //person not found create one and add it.
                newPerson = Cache.ServiceLocator.GetInstance <ICmPersonFactory>().Create();
                Cache.LanguageProject.PeopleOA.PossibilitiesOS.Add(newPerson);
                newPerson.Name.set_String(Cache.DefaultVernWs, "Jimmy Dorante");
            });
            Assert.NotNull(newPerson);

            LinguaLinksImport li = new LinguaLinksImport(Cache, null, null);

            FDO.IText text = null;
            using (var stream = new MemoryStream(Encoding.ASCII.GetBytes(xml.ToCharArray())))
            {
                li.ImportInterlinear(new DummyProgressDlg(), stream, 0, ref text);

                //If the import sets the speaker in the segment to our Jimmy, and not a new Jimmy then all is well
                Assert.AreEqual(newPerson, text.ContentsOA[0].SegmentsOS[0].SpeakerRA, "Speaker not reused.");
            }
        }
Example #2
0
 private void ExportPersonFields(TextWriter w, ICmPerson item)
 {
     if (item != null)
         ExportMultiUnicode(w, item.Alias);
 }