Exemple #1
0
        public void UpdateUserPrompt_Vern_Typing()
        {
            // Set up section head with an empty paragraph
            IScrSection section = AddSectionToMockedBook(m_book);
            IStTxtPara  para    = AddSectionHeadParaToSection(section, "",
                                                              ScrStyleNames.SectionHead);

            IVwRootBox   rootb;
            IVwSelection vwsel;
            IVwRootSite  rootsite;

            SetUpResultsForUpdateUserPromptTests(4, "t", out rootb, out vwsel, out rootsite);

            int defVernWs = Cache.DefaultVernWs;

            DummyTeStVc   stVc    = new DummyTeStVc(Cache, defVernWs, rootb);
            ITsIncStrBldr strBdlr = TsIncStrBldrClass.Create();

            strBdlr.SetIntPropValues(SimpleRootSite.ktptUserPrompt, (int)FwTextPropVar.ktpvDefault, 1);
            strBdlr.SetIntPropValues((int)FwTextPropType.ktptWs, (int)FwTextPropVar.ktpvDefault, Cache.DefaultUserWs);
            strBdlr.Append("t");
            ITsString tssTyped    = strBdlr.GetString();
            ITsString tssExpected = TsStringUtils.MakeTss("t", defVernWs);

            // Now simulate the user typing over the user prompt
            stVc.UpdateProp(vwsel, para.Hvo, SimpleRootSite.kTagUserPrompt, 0, tssTyped);

            // verify that the text is in the paragraph and that there is no longer a user prompt.
            string diff;

            Assert.IsTrue(TsStringHelper.TsStringsAreEqual(tssExpected, para.Contents, out diff), diff);

            m_vwenvMock.VerifyAllExpectations();
            VerifyArgsSentToRequestSelectionAtEndOfUow(rootsite, rootb, 0, 4, StTxtParaTags.kflidContents, "t");
        }
Exemple #2
0
        public void UserPromptChangeWSWhenPasting()
        {
            CheckDisposed();

            // Set up section head with an empty paragraph
            IScrSection section = m_inMemoryCache.AddSectionToMockedBook(m_book.Hvo);
            StTxtPara   para    = m_inMemoryCache.AddSectionHeadParaToSection(section.Hvo, "",
                                                                              ScrStyleNames.SectionHead);

            section.AdjustReferences();

            Options.ShowEmptyParagraphPromptsSetting = true;
            DynamicMock rootb = new DynamicMock(typeof(IVwRootBox));

            rootb.SetupResult("IsCompositionInProgress", false);
            DynamicMock vwsel       = new DynamicMock(typeof(IVwSelection));
            IVwRootBox  mockRootbox = (IVwRootBox)rootb.MockInstance;

            vwsel.SetupResult("RootBox", mockRootbox);
            vwsel.SetupResult("CLevels", 4, typeof(bool));
            vwsel.Ignore("AllTextSelInfo");
#if DEBUG
            vwsel.SetupResult("IsValid", true);
#endif

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

            // set up the text to paste - will be TE2ST with vernacular WS
            int             ws       = m_inMemoryCache.Cache.DefaultVernWs;
            ITsPropsFactory propFact = TsPropsFactoryClass.Create();
            ITsTextProps    ttp      = propFact.MakeProps(null, ws, 0);
            ITsStrBldr      bldr     = TsStrBldrClass.Create();
            bldr.ReplaceRgch(0, 0, "TEST", 4, ttp);
            ttp = propFact.MakeProps(ScrStyleNames.VerseNumber, ws, 0);
            bldr.ReplaceRgch(2, 2, "2", 1, ttp);
            ITsString tssVal = bldr.GetString();

            // Now simulate the user pasting over the user prompt
            stVc.UpdateProp((IVwSelection)vwsel.MockInstance, para.Hvo,
                            SimpleRootSite.kTagUserPrompt, 0, tssVal);

            // verify that the text is in the paragraph, that there is no longer a user
            // prompt, and that the ws changed but the character formatting survives.
            bldr = tssVal.GetBldr();
            bldr.SetIntPropValues(0, 5, (int)FwTextPropType.ktptWs,
                                  (int)FwTextPropVar.ktpvDefault, m_inMemoryCache.Cache.DefaultAnalWs);
            AssertEx.AreTsStringsEqual(bldr.GetString(), para.Contents.UnderlyingTsString);

            m_vwenvMock.Verify();
        }
Exemple #3
0
        public void UserPromptChangeWSWhenTyping()
        {
            CheckDisposed();

            // Set up section head with an empty paragraph
            IScrSection section = m_inMemoryCache.AddSectionToMockedBook(m_book.Hvo);
            StTxtPara   para    = m_inMemoryCache.AddSectionHeadParaToSection(section.Hvo, "",
                                                                              ScrStyleNames.SectionHead);

            section.AdjustReferences();

            Options.ShowEmptyParagraphPromptsSetting = true;
            DynamicMock rootb = new DynamicMock(typeof(IVwRootBox));

            rootb.SetupResult("IsCompositionInProgress", false);
            DynamicMock vwsel       = new DynamicMock(typeof(IVwSelection));
            IVwRootBox  mockRootbox = (IVwRootBox)rootb.MockInstance;

            vwsel.SetupResult("RootBox", mockRootbox);
            vwsel.SetupResult("CLevels", 4, typeof(bool));
            vwsel.Ignore("AllTextSelInfo");
#if DEBUG
            vwsel.SetupResult("IsValid", true);
#endif

            DummyTeStVc   stVc = new DummyTeStVc(m_inMemoryCache.Cache, m_inMemoryCache.Cache.DefaultAnalWs, mockRootbox);
            ITsStrFactory tsf  = TsStrFactoryClass.Create();
            ITsString     tssVal;
            tssVal = tsf.MakeString("TEST", m_inMemoryCache.Cache.DefaultVernWs);

            // Now simulate the user typing over the user prompt
            stVc.UpdateProp((IVwSelection)vwsel.MockInstance, para.Hvo, SimpleRootSite.kTagUserPrompt, 0, tssVal);

            // verify that the text is in the paragraph and that there is no longer a user prompt.
            ITsPropsBldr ttpBldr = TsPropsBldrClass.Create();
            ttpBldr.SetIntPropValues((int)FwTextPropType.ktptWs,
                                     (int)FwTextPropVar.ktpvDefault, m_inMemoryCache.Cache.DefaultAnalWs);
            ITsStrBldr bldr = TsStrBldrClass.Create();
            bldr.Replace(0, 0, "TEST", ttpBldr.GetTextProps());
            string diff;
            Assert.IsTrue(TsStringHelper.TsStringsAreEqual(bldr.GetString(),
                                                           para.Contents.UnderlyingTsString, out diff), diff);

            m_vwenvMock.Verify();
        }
Exemple #4
0
        public void UpdateUserPrompt_NormalBT_Pasting()
        {
            // Set up section head with an empty paragraph
            IScrSection section = AddSectionToMockedBook(m_book);
            IStTxtPara  para    = AddSectionHeadParaToSection(section, "", ScrStyleNames.SectionHead);

            int          defAnalWs = Cache.DefaultAnalWs;
            IVwRootBox   rootb;
            IVwSelection vwsel;
            IVwRootSite  rootsite;

            SetUpResultsForUpdateUserPromptTests(5, "TE2ST", out rootb, out vwsel, out rootsite);

            DummyTeStVc stVc = new DummyTeStVc(Cache, defAnalWs, rootb);
            // set up the text to paste - will be TE2ST with vernacular WS
            ITsPropsFactory propFact = TsPropsFactoryClass.Create();
            ITsTextProps    ttp      = propFact.MakeProps(null, defAnalWs, 0);

            ITsStrBldr bldr = TsStrBldrClass.Create();

            bldr.ReplaceRgch(0, 0, "TEST", 4, ttp);
            ttp = propFact.MakeProps(ScrStyleNames.VerseNumber, defAnalWs, 0);
            bldr.ReplaceRgch(2, 2, "2", 1, ttp);
            ITsString tssPasted = bldr.GetString();

            // Now simulate the user pasting over the user prompt
            ICmTranslation bt = para.GetOrCreateBT();

            stVc.UpdateProp(vwsel, bt.Hvo, SimpleRootSite.kTagUserPrompt, CmTranslationTags.kflidTranslation, tssPasted);

            // Verify that the text is in the paragraph and that the character formatting survives.
            AssertEx.AreTsStringsEqual(tssPasted, bt.Translation.get_String(defAnalWs));

            m_vwenvMock.VerifyAllExpectations();
            VerifyArgsSentToRequestSelectionAtEndOfUow(rootsite, rootb, defAnalWs, 5, CmTranslationTags.kflidTranslation, "TE2ST");
        }
Exemple #5
0
		public void UserPromptChangeWSWhenPasting()
		{
			CheckDisposed();

			// Set up section head with an empty paragraph
			IScrSection section = m_inMemoryCache.AddSectionToMockedBook(m_book.Hvo);
			StTxtPara para = m_inMemoryCache.AddSectionHeadParaToSection(section.Hvo, "",
				ScrStyleNames.SectionHead);
			section.AdjustReferences();

			Options.ShowEmptyParagraphPromptsSetting = true;
			DynamicMock rootb = new DynamicMock(typeof(IVwRootBox));
			rootb.SetupResult("IsCompositionInProgress", false);
			DynamicMock vwsel = new DynamicMock(typeof(IVwSelection));
			IVwRootBox mockRootbox = (IVwRootBox)rootb.MockInstance;
			vwsel.SetupResult("RootBox", mockRootbox);
			vwsel.SetupResult("CLevels", 4, typeof(bool));
			vwsel.Ignore("AllTextSelInfo");
#if DEBUG
			vwsel.SetupResult("IsValid", true);
#endif

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

			// set up the text to paste - will be TE2ST with vernacular WS
			int ws = m_inMemoryCache.Cache.DefaultVernWs;
			ITsPropsFactory propFact = TsPropsFactoryClass.Create();
			ITsTextProps ttp = propFact.MakeProps(null, ws, 0);
			ITsStrBldr bldr = TsStrBldrClass.Create();
			bldr.ReplaceRgch(0, 0, "TEST", 4, ttp);
			ttp = propFact.MakeProps(ScrStyleNames.VerseNumber, ws, 0);
			bldr.ReplaceRgch(2, 2, "2", 1, ttp);
			ITsString tssVal = bldr.GetString();

			// Now simulate the user pasting over the user prompt
			stVc.UpdateProp((IVwSelection)vwsel.MockInstance, para.Hvo,
				SimpleRootSite.kTagUserPrompt, 0, tssVal);

			// verify that the text is in the paragraph, that there is no longer a user
			// prompt, and that the ws changed but the character formatting survives.
			bldr = tssVal.GetBldr();
			bldr.SetIntPropValues(0, 5, (int)FwTextPropType.ktptWs,
				(int)FwTextPropVar.ktpvDefault, m_inMemoryCache.Cache.DefaultAnalWs);
			AssertEx.AreTsStringsEqual(bldr.GetString(), para.Contents.UnderlyingTsString);

			m_vwenvMock.Verify();
		}
Exemple #6
0
		public void UserPromptChangeWSWhenTyping()
		{
			CheckDisposed();

			// Set up section head with an empty paragraph
			IScrSection section = m_inMemoryCache.AddSectionToMockedBook(m_book.Hvo);
			StTxtPara para = m_inMemoryCache.AddSectionHeadParaToSection(section.Hvo, "",
				ScrStyleNames.SectionHead);
			section.AdjustReferences();

			Options.ShowEmptyParagraphPromptsSetting = true;
			DynamicMock rootb = new DynamicMock(typeof(IVwRootBox));
			rootb.SetupResult("IsCompositionInProgress", false);
			DynamicMock vwsel = new DynamicMock(typeof(IVwSelection));
			IVwRootBox mockRootbox = (IVwRootBox)rootb.MockInstance;
			vwsel.SetupResult("RootBox", mockRootbox);
			vwsel.SetupResult("CLevels", 4, typeof(bool));
			vwsel.Ignore("AllTextSelInfo");
#if DEBUG
			vwsel.SetupResult("IsValid", true);
#endif

			DummyTeStVc stVc = new DummyTeStVc(m_inMemoryCache.Cache, m_inMemoryCache.Cache.DefaultAnalWs, mockRootbox);
			ITsStrFactory tsf = TsStrFactoryClass.Create();
			ITsString tssVal;
			tssVal = tsf.MakeString("TEST", m_inMemoryCache.Cache.DefaultVernWs);

			// Now simulate the user typing over the user prompt
			stVc.UpdateProp((IVwSelection)vwsel.MockInstance, para.Hvo, SimpleRootSite.kTagUserPrompt, 0, tssVal);

			// verify that the text is in the paragraph and that there is no longer a user prompt.
			ITsPropsBldr ttpBldr = TsPropsBldrClass.Create();
			ttpBldr.SetIntPropValues((int)FwTextPropType.ktptWs,
				(int)FwTextPropVar.ktpvDefault, m_inMemoryCache.Cache.DefaultAnalWs);
			ITsStrBldr bldr = TsStrBldrClass.Create();
			bldr.Replace(0, 0, "TEST", ttpBldr.GetTextProps());
			string diff;
			Assert.IsTrue(TsStringHelper.TsStringsAreEqual(bldr.GetString(),
				para.Contents.UnderlyingTsString, out diff), diff);

			m_vwenvMock.Verify();
		}
Exemple #7
0
		public void UpdateUserPrompt_NormalBT_Pasting()
		{
			// Set up section head with an empty paragraph
			IScrSection section = AddSectionToMockedBook(m_book);
			IStTxtPara para = AddSectionHeadParaToSection(section, "", ScrStyleNames.SectionHead);

			int defAnalWs = Cache.DefaultAnalWs;
			IVwRootBox rootb;
			IVwSelection vwsel;
			IVwRootSite rootsite;
			SetUpResultsForUpdateUserPromptTests(5,	"TE2ST", out rootb, out vwsel, out rootsite);

			DummyTeStVc stVc = new DummyTeStVc(Cache, defAnalWs, rootb);
				// set up the text to paste - will be TE2ST with vernacular WS
				ITsPropsFactory propFact = TsPropsFactoryClass.Create();
				ITsTextProps ttp = propFact.MakeProps(null, defAnalWs, 0);

				ITsStrBldr bldr = TsStrBldrClass.Create();
				bldr.ReplaceRgch(0, 0, "TEST", 4, ttp);
				ttp = propFact.MakeProps(ScrStyleNames.VerseNumber, defAnalWs, 0);
				bldr.ReplaceRgch(2, 2, "2", 1, ttp);
				ITsString tssPasted = bldr.GetString();

				// Now simulate the user pasting over the user prompt
				ICmTranslation bt = para.GetOrCreateBT();
				stVc.UpdateProp(vwsel, bt.Hvo, SimpleRootSite.kTagUserPrompt, CmTranslationTags.kflidTranslation, tssPasted);

				// Verify that the text is in the paragraph and that the character formatting survives.
				AssertEx.AreTsStringsEqual(tssPasted, bt.Translation.get_String(defAnalWs));

				m_vwenvMock.VerifyAllExpectations();
				VerifyArgsSentToRequestSelectionAtEndOfUow(rootsite, rootb, defAnalWs, 5, CmTranslationTags.kflidTranslation, "TE2ST");
			}
Exemple #8
0
		public void UpdateUserPrompt_Vern_Typing()
		{
			// Set up section head with an empty paragraph
			IScrSection section = AddSectionToMockedBook(m_book);
			IStTxtPara para = AddSectionHeadParaToSection(section, "",
				ScrStyleNames.SectionHead);

			IVwRootBox rootb;
			IVwSelection vwsel;
			IVwRootSite rootsite;
			SetUpResultsForUpdateUserPromptTests(4, "t", out rootb, out vwsel, out rootsite);

			int defVernWs = Cache.DefaultVernWs;

			DummyTeStVc stVc = new DummyTeStVc(Cache, defVernWs, rootb);
				ITsIncStrBldr strBdlr = TsIncStrBldrClass.Create();
				strBdlr.SetIntPropValues(SimpleRootSite.ktptUserPrompt, (int)FwTextPropVar.ktpvDefault, 1);
				strBdlr.SetIntPropValues((int)FwTextPropType.ktptWs, (int)FwTextPropVar.ktpvDefault, Cache.DefaultUserWs);
				strBdlr.Append("t");
				ITsString tssTyped = strBdlr.GetString();
				ITsString tssExpected = TsStringUtils.MakeTss("t", defVernWs);

				// Now simulate the user typing over the user prompt
				stVc.UpdateProp(vwsel, para.Hvo, SimpleRootSite.kTagUserPrompt, 0, tssTyped);

				// verify that the text is in the paragraph and that there is no longer a user prompt.
				string diff;
				Assert.IsTrue(TsStringHelper.TsStringsAreEqual(tssExpected, para.Contents, out diff), diff);

				m_vwenvMock.VerifyAllExpectations();
				VerifyArgsSentToRequestSelectionAtEndOfUow(rootsite, rootb, 0, 4, StTxtParaTags.kflidContents, "t");
			}