Example #1
0
        public void NoUserPromptForBTWithEmptyPara()
        {
            CheckDisposed();

            // Set up a section and empty paragraph
            IScrSection section = m_inMemoryCache.AddSectionToMockedBook(m_book.Hvo);
            StTxtPara   para    = m_inMemoryCache.AddParaToMockedSectionContent(section.Hvo,
                                                                                ScrStyleNames.NormalParagraph);

            section.AdjustReferences();

            // Add an empty translation to the paragraph
            int            wsBT  = m_inMemoryCache.Cache.DefaultAnalWs;
            ICmTranslation trans = m_inMemoryCache.AddBtToMockedParagraph(para, wsBT);

            m_inMemoryCache.AddRunToMockedTrans(trans, wsBT, string.Empty, null);

            DummyTeStVc stVc = new DummyTeStVc(m_inMemoryCache.Cache, m_inMemoryCache.Cache.DefaultAnalWs);

            m_vwenvMock.ExpectNoCall("NoteDependency", new string[] { typeof(int[]).FullName,
                                                                      typeof(int[]).FullName, typeInt });
            m_vwenvMock.ExpectNoCall("AddProp", new string[] { typeInt,
                                                               typeof(IVwViewConstructor).FullName, typeInt });

            // verify that the prompt does not get added
            IVwEnv vwEnv      = (IVwEnv)m_vwenvMock.MockInstance;
            bool   fTextAdded = stVc.CallInsertBackTranslationUserPrompt(vwEnv, trans.Hvo);

            Assert.IsFalse(fTextAdded, "User prompt was added and should not have been");

            // verify the mock
            m_vwenvMock.Verify();
        }
Example #2
0
        public void UserPromptForBackTranslation()
        {
            CheckDisposed();

            // Set up a section and paragraph with text
            IScrSection section = m_inMemoryCache.AddSectionToMockedBook(m_book.Hvo);
            StTxtPara   para    = m_inMemoryCache.AddParaToMockedSectionContent(section.Hvo,
                                                                                ScrStyleNames.NormalParagraph);

            section.AdjustReferences();

            m_inMemoryCache.AddRunToMockedPara(para, "Some paragraph text.", null);

            // Add an empty translation to the paragraph
            int            wsBT  = m_inMemoryCache.Cache.DefaultAnalWs;
            ICmTranslation trans = m_inMemoryCache.AddBtToMockedParagraph(para, wsBT);

            m_inMemoryCache.AddRunToMockedTrans(trans, wsBT, string.Empty, null);

            DummyTeStVc stVc = new DummyTeStVc(m_inMemoryCache.Cache, m_inMemoryCache.Cache.DefaultAnalWs);

            CreateExpectedUserPrompt(stVc, trans.Hvo,
                                     (int)CmTranslation.CmTranslationTags.kflidTranslation,
                                     (int)CmTranslation.CmTranslationTags.kflidTranslation);

            // verify that the prompt gets added
            IVwEnv vwEnv      = (IVwEnv)m_vwenvMock.MockInstance;
            bool   fTextAdded = stVc.CallInsertBackTranslationUserPrompt(vwEnv, trans.Hvo);

            Assert.IsTrue(fTextAdded, "User prompt not added");

            // verify the contents of the prompt
            ITsString text = stVc.DisplayVariant(vwEnv, SimpleRootSite.kTagUserPrompt, null,
                                                 (int)CmTranslation.CmTranslationTags.kflidTranslation);
            string difference;
            bool   fEqual = TsStringHelper.TsStringsAreEqual(
                ExpectedUserPrompt("Type back translation here", m_inMemoryCache.Cache.DefaultAnalWs),
                text, out difference);

            Assert.IsTrue(fEqual, difference);

            // verify the mock - is this useful?
            m_vwenvMock.Verify();
        }
Example #3
0
        public void NoUserPromptForBTWithEmptyPara()
        {
            // Set up a section and empty paragraph
            IScrSection section = AddSectionToMockedBook(m_book);
            IStTxtPara  para    = AddParaToMockedSectionContent(section, ScrStyleNames.NormalParagraph);

            // Add an empty translation to the paragraph
            int            wsBT  = Cache.DefaultAnalWs;
            ICmTranslation trans = AddBtToMockedParagraph(para, wsBT);

            AddRunToMockedTrans(trans, wsBT, string.Empty, null);

            DummyTeStVc stVc = new DummyTeStVc(Cache, wsBT);
            // verify that the prompt does not get added
            bool fTextAdded = stVc.CallInsertBackTranslationUserPrompt(m_vwenvMock, trans);

            Assert.IsFalse(fTextAdded, "User prompt was added and should not have been");

            m_vwenvMock.AssertWasNotCalled(x => x.NoteDependency(Arg <int[]> .Is.Anything, Arg <int[]> .Is.Anything, Arg <int> .Is.Anything));
            m_vwenvMock.AssertWasNotCalled(x => x.AddProp(Arg <int> .Is.Anything, Arg <IVwViewConstructor> .Is.Anything, Arg <int> .Is.Anything));
            m_vwenvMock.VerifyAllExpectations();
        }
Example #4
0
        public void UserPromptForBackTranslation()
        {
            // Set up a section and paragraph with text
            IScrSection section = AddSectionToMockedBook(m_book);
            IStTxtPara  para    = AddParaToMockedSectionContent(section, ScrStyleNames.NormalParagraph);

            AddRunToMockedPara(para, "Some paragraph text.", null);

            // Add an empty translation to the paragraph
            int            wsBT  = Cache.DefaultAnalWs;
            ICmTranslation trans = AddBtToMockedParagraph(para, wsBT);

            AddRunToMockedTrans(trans, wsBT, string.Empty, null);

            DummyTeStVc stVc = new DummyTeStVc(Cache, wsBT);

            CreateExpectedUserPrompt(stVc, trans.Hvo, CmTranslationTags.kflidTranslation,
                                     CmTranslationTags.kflidTranslation);

            // verify that the prompt gets added
            bool fTextAdded = stVc.CallInsertBackTranslationUserPrompt(m_vwenvMock, trans);

            Assert.IsTrue(fTextAdded, "User prompt not added");

            // verify the contents of the prompt
            ITsString text = stVc.DisplayVariant(m_vwenvMock, SimpleRootSite.kTagUserPrompt,
                                                 CmTranslationTags.kflidTranslation);
            string difference;
            bool   fEqual = TsStringHelper.TsStringsAreEqual(
                ExpectedUserPrompt("Type back translation here", wsBT),
                text, out difference);

            Assert.IsTrue(fEqual, difference);

            // verify the mock - is this useful?
            m_vwenvMock.VerifyAllExpectations();
        }
Example #5
0
        public void NoUserPromptForBTWithText()
        {
            // Set up a section and paragraph with text
            IScrSection section = AddSectionToMockedBook(m_book);
            IStTxtPara  para    = AddParaToMockedSectionContent(section, ScrStyleNames.NormalParagraph);

            AddRunToMockedPara(para, "Some paragraph text.", null);

            // Add a translation to the paragraph. The mock for the AltString provides text by default.
            int            wsBT  = Cache.DefaultAnalWs;
            ICmTranslation trans = AddBtToMockedParagraph(para, wsBT);

            AddRunToMockedTrans(trans, wsBT, "this is text in the BT", null);

            DummyTeStVc stVc = new DummyTeStVc(Cache, wsBT);
            // verify that the prompt does not get added
            bool fTextAdded = stVc.CallInsertBackTranslationUserPrompt(m_vwenvMock, trans);

            Assert.IsFalse(fTextAdded, "User prompt added when it should not have been");

            m_vwenvMock.AssertWasNotCalled(x => x.NoteDependency(Arg <int[]> .Is.Anything, Arg <int[]> .Is.Anything, Arg <int> .Is.Anything));
            m_vwenvMock.AssertWasNotCalled(x => x.AddProp(Arg <int> .Is.Anything, Arg <IVwViewConstructor> .Is.Anything, Arg <int> .Is.Anything));
            m_vwenvMock.VerifyAllExpectations();
        }
Example #6
0
		public void NoUserPromptForBTWithEmptyPara()
		{
			CheckDisposed();

			// Set up a section and empty paragraph
			IScrSection section = m_inMemoryCache.AddSectionToMockedBook(m_book.Hvo);
			StTxtPara para = m_inMemoryCache.AddParaToMockedSectionContent(section.Hvo,
				ScrStyleNames.NormalParagraph);
			section.AdjustReferences();

			// Add an empty translation to the paragraph
			int wsBT = m_inMemoryCache.Cache.DefaultAnalWs;
			ICmTranslation trans = m_inMemoryCache.AddBtToMockedParagraph(para, wsBT);
			m_inMemoryCache.AddRunToMockedTrans(trans, wsBT, string.Empty, null);

			DummyTeStVc stVc = new DummyTeStVc(m_inMemoryCache.Cache, m_inMemoryCache.Cache.DefaultAnalWs);

			m_vwenvMock.ExpectNoCall("NoteDependency", new string[] { typeof(int[]).FullName,
				typeof(int[]).FullName, typeInt });
			m_vwenvMock.ExpectNoCall("AddProp", new string[] { typeInt,
				typeof(IVwViewConstructor).FullName, typeInt });

			// verify that the prompt does not get added
			IVwEnv vwEnv = (IVwEnv)m_vwenvMock.MockInstance;
			bool fTextAdded = stVc.CallInsertBackTranslationUserPrompt(vwEnv, trans.Hvo);
			Assert.IsFalse(fTextAdded, "User prompt was added and should not have been");

			// verify the mock
			m_vwenvMock.Verify();
		}
Example #7
0
		public void UserPromptForBackTranslation()
		{
			CheckDisposed();

			// Set up a section and paragraph with text
			IScrSection section = m_inMemoryCache.AddSectionToMockedBook(m_book.Hvo);
			StTxtPara para = m_inMemoryCache.AddParaToMockedSectionContent(section.Hvo,
				ScrStyleNames.NormalParagraph);
			section.AdjustReferences();

			m_inMemoryCache.AddRunToMockedPara(para, "Some paragraph text.", null);

			// Add an empty translation to the paragraph
			int wsBT = m_inMemoryCache.Cache.DefaultAnalWs;
			ICmTranslation trans = m_inMemoryCache.AddBtToMockedParagraph(para, wsBT);
			m_inMemoryCache.AddRunToMockedTrans(trans, wsBT, string.Empty, null);

			DummyTeStVc stVc = new DummyTeStVc(m_inMemoryCache.Cache, m_inMemoryCache.Cache.DefaultAnalWs);

			CreateExpectedUserPrompt(stVc, trans.Hvo,
				(int)CmTranslation.CmTranslationTags.kflidTranslation,
				(int)CmTranslation.CmTranslationTags.kflidTranslation);

			// verify that the prompt gets added
			IVwEnv vwEnv = (IVwEnv)m_vwenvMock.MockInstance;
			bool fTextAdded = stVc.CallInsertBackTranslationUserPrompt(vwEnv, trans.Hvo);
			Assert.IsTrue(fTextAdded, "User prompt not added");

			// verify the contents of the prompt
			ITsString text = stVc.DisplayVariant(vwEnv, SimpleRootSite.kTagUserPrompt, null,
				(int)CmTranslation.CmTranslationTags.kflidTranslation);
			string difference;
			bool fEqual = TsStringHelper.TsStringsAreEqual(
				ExpectedUserPrompt("Type back translation here", m_inMemoryCache.Cache.DefaultAnalWs),
				text, out difference);
			Assert.IsTrue(fEqual, difference);

			// verify the mock - is this useful?
			m_vwenvMock.Verify();
		}
Example #8
0
		public void NoUserPromptForBTWithEmptyPara()
		{
			// Set up a section and empty paragraph
			IScrSection section = AddSectionToMockedBook(m_book);
			IStTxtPara para = AddParaToMockedSectionContent(section, ScrStyleNames.NormalParagraph);

			// Add an empty translation to the paragraph
			int wsBT = Cache.DefaultAnalWs;
			ICmTranslation trans = AddBtToMockedParagraph(para, wsBT);
			AddRunToMockedTrans(trans, wsBT, string.Empty, null);

			DummyTeStVc stVc = new DummyTeStVc(Cache, wsBT);
				// verify that the prompt does not get added
				bool fTextAdded = stVc.CallInsertBackTranslationUserPrompt(m_vwenvMock, trans);
				Assert.IsFalse(fTextAdded, "User prompt was added and should not have been");

				m_vwenvMock.AssertWasNotCalled(x => x.NoteDependency(Arg<int[]>.Is.Anything, Arg<int[]>.Is.Anything, Arg<int>.Is.Anything));
				m_vwenvMock.AssertWasNotCalled(x => x.AddProp(Arg<int>.Is.Anything, Arg<IVwViewConstructor>.Is.Anything, Arg<int>.Is.Anything));
				m_vwenvMock.VerifyAllExpectations();
			}
Example #9
0
		public void NoUserPromptForBTWithText()
		{
			// Set up a section and paragraph with text
			IScrSection section = AddSectionToMockedBook(m_book);
			IStTxtPara para = AddParaToMockedSectionContent(section, ScrStyleNames.NormalParagraph);

			AddRunToMockedPara(para, "Some paragraph text.", null);

			// Add a translation to the paragraph. The mock for the AltString provides text by default.
			int wsBT = Cache.DefaultAnalWs;
			ICmTranslation trans = AddBtToMockedParagraph(para, wsBT);
			AddRunToMockedTrans(trans, wsBT, "this is text in the BT", null);

			DummyTeStVc stVc = new DummyTeStVc(Cache, wsBT);
				// verify that the prompt does not get added
				bool fTextAdded = stVc.CallInsertBackTranslationUserPrompt(m_vwenvMock, trans);
				Assert.IsFalse(fTextAdded, "User prompt added when it should not have been");

				m_vwenvMock.AssertWasNotCalled(x => x.NoteDependency(Arg<int[]>.Is.Anything, Arg<int[]>.Is.Anything, Arg<int>.Is.Anything));
				m_vwenvMock.AssertWasNotCalled(x => x.AddProp(Arg<int>.Is.Anything, Arg<IVwViewConstructor>.Is.Anything, Arg<int>.Is.Anything));
				m_vwenvMock.VerifyAllExpectations();
			}
Example #10
0
		public void UserPromptForBackTranslation()
		{
			// Set up a section and paragraph with text
			IScrSection section = AddSectionToMockedBook(m_book);
			IStTxtPara para = AddParaToMockedSectionContent(section, ScrStyleNames.NormalParagraph);

			AddRunToMockedPara(para, "Some paragraph text.", null);

			// Add an empty translation to the paragraph
			int wsBT = Cache.DefaultAnalWs;
			ICmTranslation trans = AddBtToMockedParagraph(para, wsBT);
			AddRunToMockedTrans(trans, wsBT, string.Empty, null);

			DummyTeStVc stVc = new DummyTeStVc(Cache, wsBT);
				CreateExpectedUserPrompt(stVc, trans.Hvo, CmTranslationTags.kflidTranslation,
					CmTranslationTags.kflidTranslation);

				// verify that the prompt gets added
				bool fTextAdded = stVc.CallInsertBackTranslationUserPrompt(m_vwenvMock, trans);
				Assert.IsTrue(fTextAdded, "User prompt not added");

				// verify the contents of the prompt
				ITsString text = stVc.DisplayVariant(m_vwenvMock, SimpleRootSite.kTagUserPrompt,
					CmTranslationTags.kflidTranslation);
				string difference;
				bool fEqual = TsStringHelper.TsStringsAreEqual(
					ExpectedUserPrompt("Type back translation here", wsBT),
					text, out difference);
				Assert.IsTrue(fEqual, difference);

				// verify the mock - is this useful?
				m_vwenvMock.VerifyAllExpectations();
			}