public void CreateBtWhenBookTitleParagraphIsAdded()
		{
			CheckDisposed();

			// add title paragraphs
			StText title = m_scrInMemoryCache.AddTitleToMockedBook(m_book.Hvo,
				"Genesis or whatever");
			StTxtPara para2 = m_scrInMemoryCache.AddParaToMockedText(title.Hvo, "An anthology");
			StTxtPara para3 = m_scrInMemoryCache.AddParaToMockedText(title.Hvo, "Written by God");
			m_scrInMemoryCache.AddParaToMockedText(title.Hvo, "For Israel and everyone else");

			// set up the Scripture paragraph ChangeWatcher
			ScriptureChangeWatcher.Create(Cache);

			// Issue a PropChanged that should create a back translation paragraph.
			Cache.MainCacheAccessor.PropChanged(null,
				(int)PropChangeType.kpctNotifyAll,
				title.Hvo,
				(int)StText.StTextTags.kflidParagraphs,
				1, 2, 0);

			// Make sure the back translations got created.
			ScrTxtPara scrPara = new ScrTxtPara(Cache, para2.Hvo);
			ICmTranslation bt = scrPara.GetBT();
			Assert.IsNotNull(bt);
			Assert.IsNull(bt.Status.AnalysisDefaultWritingSystem);

			scrPara = new ScrTxtPara(Cache, para3.Hvo);
			bt = scrPara.GetBT();
			Assert.IsNotNull(bt);
			Assert.IsNull(bt.Status.AnalysisDefaultWritingSystem);
		}
		public void CreateBtsWhenContentParagraphIsReplacedByMultipleOtherParagraphs()
		{
			CheckDisposed();

			// add scripture section and paragraph
			IScrSection section = m_scrInMemoryCache.AddSectionToMockedBook(m_book.Hvo);
			StTxtPara para1 = m_scrInMemoryCache.AddParaToMockedSectionContent(section.Hvo,
				ScrStyleNames.IntroParagraph);
			StTxtPara para2 = m_scrInMemoryCache.AddParaToMockedSectionContent(section.Hvo,
				ScrStyleNames.IntroParagraph);
			StTxtPara para3 = m_scrInMemoryCache.AddParaToMockedSectionContent(section.Hvo,
				ScrStyleNames.IntroParagraph);

			// set up the Scripture paragraph ChangeWatcher
			ScriptureChangeWatcher.Create(Cache);

			// Issue a PropChanged that should create a back translation paragraph.
			Cache.MainCacheAccessor.PropChanged(null,
				(int)PropChangeType.kpctNotifyAll,
				section.ContentOA.Hvo,
				(int)StText.StTextTags.kflidParagraphs,
				0, 3, 1);

			// make sure the back translations got created.
			ScrTxtPara scrPara = new ScrTxtPara(Cache, para1.Hvo);
			ICmTranslation bt = scrPara.GetBT();
			Assert.IsNotNull(bt);
			Assert.IsNull(bt.Status.AnalysisDefaultWritingSystem);

			scrPara = new ScrTxtPara(Cache, para2.Hvo);
			bt = scrPara.GetBT();
			Assert.IsNotNull(bt);
			Assert.IsNull(bt.Status.AnalysisDefaultWritingSystem);

			scrPara = new ScrTxtPara(Cache, para3.Hvo);
			bt = scrPara.GetBT();
			Assert.IsNotNull(bt);
			Assert.IsNull(bt.Status.AnalysisDefaultWritingSystem);
		}
		public void CreateBtWhenHeadingParagraphIsAdded()
		{
			CheckDisposed();

			// add scripture section and paragraph
			IScrSection section = m_scrInMemoryCache.AddSectionToMockedBook(m_book.Hvo);
			StTxtPara para = m_scrInMemoryCache.AddSectionHeadParaToSection(section.Hvo,
				"Intro to Genesis or whatever", ScrStyleNames.IntroSectionHead);

			// set up the Scripture paragraph ChangeWatcher
			ScriptureChangeWatcher.Create(Cache);

			// Issue a PropChanged that should create a back translation paragraph.
			Cache.MainCacheAccessor.PropChanged(null,
				(int)PropChangeType.kpctNotifyAll,
				section.HeadingOA.Hvo,
				(int)StText.StTextTags.kflidParagraphs,
				0, 1, 0);

			// make sure the back translation is created.
			ScrTxtPara scrPara = new ScrTxtPara(Cache, para.Hvo);
			ICmTranslation bt = scrPara.GetBT();
			Assert.IsNotNull(bt);
			Assert.IsNull(bt.Status.AnalysisDefaultWritingSystem);
		}
Exemple #4
0
		public void TransWithValidAndNullTypes()
		{
			CheckDisposed();

			AddDataToMatthew();
			ScrSection section = (ScrSection)m_book.SectionsOS[1];
			ScrTxtPara para = new ScrTxtPara(Cache, section.ContentOA.ParagraphsOS.HvoArray[0]);

			// Set up a second and third translation. The first one already had the type set.
			para.TranslationsOC.Add(new CmTranslation());
			para.TranslationsOC.Add(new CmTranslation());

			Assert.AreEqual(para.TranslationsOC.Count, 3,
				"We expect to have three translations owned by the paragraph.");
			CmTranslation testTrans = (CmTranslation)para.GetBT();
			Assert.AreEqual(para.TranslationsOC.Count, 1,
				"We expect to have only one translation owned by the paragraph." +
				"The back translation without a type should have been deleted.");
			CmTranslation trans = new CmTranslation(Cache, para.TranslationsOC.HvoArray[0]);
			Assert.AreEqual(trans.TypeRA.Guid, new Guid("80a0dddb-8b4b-4454-b872-88adec6f2aba"),
				"We expect the translation to be of type back translation.");
		}