コード例 #1
0
        public void FormatApplyStyle_DisabledWhenNeitherParaNorCharCanBeFormatted()
        {
            SelectionHelper mockedSelectionHelper = MockRepository.GenerateMock <SelectionHelper>();
            IVwSelection    mockedSelection       = MockRepository.GenerateStub <IVwSelection>();

            mockedSelection.Expect(sel => sel.IsEditable).Return(true);
            mockedSelection.Stub(sel => sel.CanFormatChar).Return(false);
            mockedSelection.Stub(sel => sel.CanFormatPara).Return(false);
            mockedSelectionHelper.Expect(sh => sh.Selection).Return(mockedSelection);
            m_mainWnd.m_mockedEditingHelper.Expect(ed => ed.CurrentSelection).Return(mockedSelectionHelper);

            Assert.IsTrue(m_mainWnd.OnUpdateFormatApplyStyle(m_itemProps));
            Assert.IsFalse(m_itemProps.Enabled);
        }
コード例 #2
0
        public void InsertFootnote_DisabledWhenSelectionRangeCrossesBooks()
        {
            m_mainWnd.MockedBookFilter.Stub(bf => bf.BookCount).Return(1);
            m_mainWnd.m_mockedEditingHelper.Stub(e => e.IsPictureSelected).Return(false);
            m_mainWnd.m_mockedEditingHelper.Stub(e => e.TheClientWnd).Return(MockRepository.GenerateMock <ISelectableView>());
            m_mainWnd.m_mockedEditingHelper.Stub(
                e => e.GetSelectedScrElement(out Arg <int> .Out(0).Dummy, out Arg <int> .Out(0).Dummy)).Return(true);
            m_mainWnd.m_mockedEditingHelper.Stub(
                e => e.GetBookIndex(SelectionHelper.SelLimitType.Anchor)).Return(1);
            m_mainWnd.m_mockedEditingHelper.Stub(
                e => e.GetBookIndex(SelectionHelper.SelLimitType.End)).Return(2);

            IVwSelection sel = MockRepository.GenerateMock <IVwSelection>();

            sel.Stub(s => s.IsRange).Return(true);

            SelectionHelper selHelper = MockRepository.GenerateMock <SelectionHelper>();

            selHelper.Stub(sh => sh.Selection).Return(sel);
            selHelper.Stub(s => s.IsRange).Return(true);
            m_mainWnd.m_mockedEditingHelper.Stub(e => e.CurrentSelection).Return(selHelper);

            Assert.IsTrue(m_mainWnd.OnUpdateInsertGeneralFootnote(m_dummyItemProps));
            Assert.IsFalse(m_dummyItemProps.Enabled, "Insert Footnote should be disabled.");
        }
コード例 #3
0
        public void FormatApplyStyle_EnabledWhenCurrentSelection()
        {
            SelectionHelper mockedSelectionHelper = MockRepository.GenerateMock <SelectionHelper>();
            IVwSelection    mockedSelection       = MockRepository.GenerateMock <IVwSelection>();

            mockedSelection.Expect(sel => sel.IsEditable).Return(true);
            mockedSelection.Stub(sel => sel.CanFormatChar).Return(true);
            mockedSelection.Stub(sel => sel.CanFormatPara).Return(true);
            mockedSelectionHelper.Expect(sh => sh.Selection).Return(mockedSelection);
            m_mainWnd.m_mockedEditingHelper.Expect(ed => ed.CurrentSelection).Return(mockedSelectionHelper);

            Assert.IsTrue(m_mainWnd.OnUpdateFormatApplyStyle(m_itemProps));
            Assert.IsTrue(m_itemProps.Enabled);
            mockedSelectionHelper.VerifyAllExpectations();
            mockedSelection.VerifyAllExpectations();
            m_mainWnd.m_mockedEditingHelper.VerifyAllExpectations();
        }
コード例 #4
0
        private void SetUpMocksForOnAddWordGlossesToFreeTransTest(ISegment seg)
        {
            IVwRootBox rootb = MockRepository.GenerateMock <IVwRootBox>();

            m_interlinDoc.MockedRootBox = rootb;
            IVwSelection vwsel = MockRepository.GenerateMock <IVwSelection>();

            rootb.Stub(x => x.Selection).Return(vwsel);
            rootb.Stub(x => x.DataAccess).Return(Cache.DomainDataByFlid);
            vwsel.Stub(x => x.TextSelInfo(Arg <bool> .Is.Equal(false), out Arg <ITsString> .Out(null).Dummy,
                                          out Arg <int> .Out(0).Dummy, out Arg <bool> .Out(false).Dummy, out Arg <int> .Out(seg.Hvo).Dummy,
                                          out Arg <int> .Out(SimpleRootSite.kTagUserPrompt).Dummy, out Arg <int> .Out(Cache.DefaultAnalWs).Dummy));
            vwsel.Stub(x => x.IsValid).Return(true);
            vwsel.Stub(x => x.CLevels(Arg <bool> .Is.Anything)).Return(0);
            vwsel.Stub(x => x.AllSelEndInfo(Arg <bool> .Is.Anything, out Arg <int> .Out(0).Dummy, Arg <int> .Is.Equal(0),
                                            Arg <ArrayPtr> .Is.Null, out Arg <int> .Out(0).Dummy, out Arg <int> .Out(0).Dummy, out Arg <int> .Out(0).Dummy,
                                            out Arg <int> .Out(0).Dummy, out Arg <bool> .Out(true).Dummy, out Arg <ITsTextProps> .Out(null).Dummy));
            m_interlinDoc.CallSetActiveFreeform(seg.Hvo, Cache.DefaultAnalWs);
        }
コード例 #5
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Sets up results for user prompt change tests (mostly creates and sets up mock
        /// objects to stub out methods).
        /// </summary>
        /// <param name="cLevels">The count of selection levels.</param>
        /// <param name="text">The text that was typed or pasted to replace the prompt.</param>
        /// <param name="rootb">The (mocked) root box.</param>
        /// <param name="vwsel">The (mocked) vw selection.</param>
        /// <param name="rootsite">The (mocked) rootsite.</param>
        /// ------------------------------------------------------------------------------------
        private static void SetUpResultsForUpdateUserPromptTests(int cLevels, string text,
                                                                 out IVwRootBox rootb, out IVwSelection vwsel, out IVwRootSite rootsite)
        {
            Options.ShowEmptyParagraphPromptsSetting = true;
            IVwRootBox rootbox = rootb = MockRepository.GenerateMock <IVwRootBox>();

            rootb.Stub(x => x.IsCompositionInProgress).Return(false);
            rootsite = MockRepository.GenerateMock <IVwRootSite>();
            rootb.Stub(x => x.Site).Return(rootsite);
            vwsel = MockRepository.GenerateMock <IVwSelection>();
            vwsel.Stub(x => x.RootBox).Return(rootb);
            // The number of levels CLevels reports includes one for the string property, so we add that here (production code subtracts it)
            vwsel.Stub(x => x.CLevels(Arg <bool> .Is.Anything)).Return(cLevels + 1);
            vwsel.Stub(x => x.AllTextSelInfo(out Arg <int> .Out(0).Dummy, Arg <int> .Is.Equal(cLevels),
                                             Arg <ArrayPtr> .Is.Anything, out Arg <int> .Out(0).Dummy, out Arg <int> .Out(0).Dummy,
                                             out Arg <int> .Out(0).Dummy, out Arg <int> .Out(text.Length).Dummy, out Arg <int> .Out(0).Dummy,
                                             out Arg <bool> .Out(false).Dummy, out Arg <int> .Out(0).Dummy,
                                             out Arg <ITsTextProps> .Out(null).Dummy));
#if DEBUG
            vwsel.Stub(x => x.IsValid).Return(true);
#endif
        }
コード例 #6
0
        public void InsertFootnote_EnabledInSegmentedBT()
        {
            m_mainWnd.MockedBookFilter.Stub(bf => bf.BookCount).Return(1);
            m_mainWnd.m_mockedEditingHelper.Stub(e => e.InSegmentedBt).Return(true);
            m_mainWnd.m_mockedEditingHelper.Stub(e => e.IsPictureSelected).Return(false);
            m_mainWnd.m_mockedEditingHelper.Stub(e => e.TheClientWnd).Return(MockRepository.GenerateMock <ISelectableView>());
            m_mainWnd.m_mockedEditingHelper.Stub(
                e => e.GetSelectedScrElement(out Arg <int> .Out(0).Dummy, out Arg <int> .Out(0).Dummy)).Return(true);

            IVwSelection sel = MockRepository.GenerateMock <IVwSelection>();

            sel.Stub(s => s.IsRange).Return(false);

            SelectionHelper selHelper = MockRepository.GenerateMock <SelectionHelper>();

            selHelper.Stub(sh => sh.Selection).Return(sel);
            m_mainWnd.m_mockedEditingHelper.Stub(e => e.CurrentSelection).Return(selHelper);

            Assert.IsTrue(m_mainWnd.OnUpdateInsertGeneralFootnote(m_dummyItemProps));
            Assert.IsTrue(m_dummyItemProps.Enabled, "Insert Footnote should be enabled when in a segmented BT.");
        }
コード例 #7
0
        public void InsertChapterNumber_EnabledInScripture()
        {
            IVwSelection    sel       = MockRepository.GenerateMock <IVwSelection>();
            SelectionHelper selHelper = MockRepository.GenerateMock <SelectionHelper>();

            selHelper.Stub(sh => sh.Selection).Return(sel);
            sel.Stub(x => x.TextSelInfo(Arg <bool> .Is.Equal(false), out Arg <ITsString> .Out(null).Dummy,
                                        out Arg <int> .Out(0).Dummy, out Arg <bool> .Out(false).Dummy, out Arg <int> .Out(0).Dummy,
                                        out Arg <int> .Out(CmTranslationTags.kflidTranslation).Dummy, out Arg <int> .Out(0).Dummy));
            selHelper.Stub(sh => sh.ReduceSelectionToIp(SelectionHelper.SelLimitType.Top, false, false)).Return(selHelper);
            m_mainWnd.m_mockedEditingHelper.Stub(e => e.CurrentSelection).Return(selHelper);
            m_mainWnd.m_mockedEditingHelper.Stub(e => e.IsPictureSelected).Return(false);
            m_mainWnd.m_mockedEditingHelper.Stub(e => e.CanInsertNumberInElement).Return(true);
            m_mainWnd.MockedBookFilter.Stub(bf => bf.BookCount).Return(3);
            m_mainWnd.m_mockedEditingHelper.Stub(e => e.IsBackTranslation).Return(false);

            Assert.IsTrue(m_mainWnd.OnUpdateInsertChapterNumber(m_dummyItemProps));

            Assert.IsTrue(m_dummyItemProps.Enabled,
                          "Insert Chapter should be enabled when in Scripture text.");
        }
コード例 #8
0
ファイル: TeStVcTests.cs プロジェクト: bbriggs/FieldWorks
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Sets up results for user prompt change tests (mostly creates and sets up mock
		/// objects to stub out methods).
		/// </summary>
		/// <param name="cLevels">The count of selection levels.</param>
		/// <param name="text">The text that was typed or pasted to replace the prompt.</param>
		/// <param name="rootb">The (mocked) root box.</param>
		/// <param name="vwsel">The (mocked) vw selection.</param>
		/// <param name="rootsite">The (mocked) rootsite.</param>
		/// ------------------------------------------------------------------------------------
		private static void SetUpResultsForUpdateUserPromptTests(int cLevels, string text,
			out IVwRootBox rootb, out IVwSelection vwsel, out IVwRootSite rootsite)
		{
			Options.ShowEmptyParagraphPromptsSetting = true;
			IVwRootBox rootbox = rootb = MockRepository.GenerateMock<IVwRootBox>();
			rootb.Stub(x => x.IsCompositionInProgress).Return(false);
			rootsite = MockRepository.GenerateMock<IVwRootSite>();
			rootb.Stub(x => x.Site).Return(rootsite);
			vwsel = MockRepository.GenerateMock<IVwSelection>();
			vwsel.Stub(x => x.RootBox).Return(rootb);
			// The number of levels CLevels reports includes one for the string property, so we add that here (production code subtracts it)
			vwsel.Stub(x => x.CLevels(Arg<bool>.Is.Anything)).Return(cLevels + 1);
			vwsel.Stub(x => x.AllTextSelInfo(out Arg<int>.Out(0).Dummy, Arg<int>.Is.Equal(cLevels),
				Arg<ArrayPtr>.Is.Anything, out Arg<int>.Out(0).Dummy, out Arg<int>.Out(0).Dummy,
				out Arg<int>.Out(0).Dummy, out Arg<int>.Out(text.Length).Dummy, out Arg<int>.Out(0).Dummy,
				out Arg<bool>.Out(false).Dummy, out Arg<int>.Out(0).Dummy,
				out Arg<ITsTextProps>.Out(null).Dummy));
#if DEBUG
			vwsel.Stub(x => x.IsValid).Return(true);
#endif
		}