Ejemplo n.º 1
0
		public void CreateAndUpdateSingleFt()
		{
			string paraContents = "Das buch ist rot";
			string trans = "The book is red";
			m_para.Contents.UnderlyingTsString = m_tsf.MakeString(paraContents, m_wsVern);
			ICmIndirectAnnotation ft = MakeFt(m_para, trans, 0, paraContents.Length);
			FreeTransEditMonitor monitor = new FreeTransEditMonitor(Cache, m_wsTrans); // BEFORE propChanged!
			Cache.PropChanged(ft.Hvo, (int)CmAnnotation.CmAnnotationTags.kflidComment, 0, 0, 0);
			monitor.LoseFocus();
			Assert.AreEqual(1, m_para.TranslationsOC.Count, "monitor should have made a CmTranslation");
			Assert.AreEqual(trans, m_para.TranslationsOC.ToList()[0].Translation.GetAlternative(m_wsTrans).Text);
			string trans2 = "The book is green";
			ft.Comment.SetAlternative(trans2, m_wsTrans);
			monitor.Dispose(); // should trigger update.
			Assert.AreEqual(1, m_para.TranslationsOC.Count, "monitor should not have made another translation");
			Assert.AreEqual(trans2, m_para.TranslationsOC.ToList()[0].Translation.GetAlternative(m_wsTrans).Text);
		}
Ejemplo n.º 2
0
		public void CreateAndUpdateOneOfTwoFts()
		{
			string pc1 = "Das buch ist rot. ";
			string pc2 = "Das Madchen ist shon.";
			string verse1 = "9";
			m_para.Contents.UnderlyingTsString = m_tsf.MakeString(pc1 + verse1 + pc2, m_wsVern);
			string trans1 = "The book is red.";
			string trans2 = "The girl is beautiful";
			ICmIndirectAnnotation ft = MakeFt(m_para, trans1, 0, pc1.Length);
			ICmBaseAnnotation verseSeg = MakeVerseSegment(m_para, pc1.Length, verse1.Length);
			ICmIndirectAnnotation ft2 = MakeFt(m_para, trans2, pc1.Length + verse1.Length, pc2.Length);
			FreeTransEditMonitor monitor = new FreeTransEditMonitor(Cache, m_wsTrans); // BEFORE propChanged!
			Cache.PropChanged(ft.Hvo, (int)CmAnnotation.CmAnnotationTags.kflidComment, 0, 0, 0);
			Cache.PropChanged(ft.Hvo, (int)CmAnnotation.CmAnnotationTags.kflidComment, 0, 0, 0);
			Assert.AreEqual(0, m_para.TranslationsOC.Count, "monitor should not have updated for change to same ft.");

			Cache.PropChanged(ft2.Hvo, (int)CmAnnotation.CmAnnotationTags.kflidComment, 0, 0, 0);

			Assert.AreEqual(1, m_para.TranslationsOC.Count, "monitor should have updated on changing another property");
			Assert.AreEqual(trans1 + " " + verse1 + trans2,
				m_para.TranslationsOC.ToList()[0].Translation.GetAlternative(m_wsTrans).Text,
				"translation should be correct after changing prop2");

			string trans2b = "The girl is pretty.";
			ft2.Comment.SetAlternative(trans2b, m_wsTrans); // should generate propChanged for same prop.
			Assert.AreEqual(trans1 + " " + verse1 + trans2,
				m_para.TranslationsOC.ToList()[0].Translation.GetAlternative(m_wsTrans).Text,
				"Another change to same prop should not produce yet another update");
			monitor.Dispose();
			Assert.AreEqual(trans1 + " " + verse1 + trans2b,
				m_para.TranslationsOC.ToList()[0].Translation.GetAlternative(m_wsTrans).Text,
				"Should get final update on Dispose");
		}