Exemplo n.º 1
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Set the location of the m_selection
 /// </summary>
 /// <param name="rcPrimary">m_selection rectangle (from top of view)</param>
 /// <param name="fEndBeforeAnchor"><c>true</c> if end is before anchor</param>
 /// <param name="scrollPos">The scroll position</param>
 /// <param name="fIsRange"><c>true</c> if it is a range m_selection</param>
 /// ------------------------------------------------------------------------------------
 protected void SetLocation(Rect rcPrimary, bool fEndBeforeAnchor, Point scrollPos,
                            bool fIsRange)
 {
     m_selection.Expect(s =>
     {
         Rect outRect;
         bool outJunk;
         s.Location(null, new Rect(), new Rect(), out rcPrimary, out outRect, out outJunk,
                    out fEndBeforeAnchor);
     }).IgnoreArguments().OutRef(new Rect(rcPrimary.left - scrollPos.X, rcPrimary.top - scrollPos.Y, rcPrimary.right - scrollPos.X,
                                          rcPrimary.bottom - scrollPos.Y), new Rect(0, 0, 0, 0), false, fEndBeforeAnchor);
     m_selection.Expect(s => s.IsRange).Return(fIsRange);
     m_selection.Expect(s => s.SelType).Return(VwSelType.kstText);
     m_selection.Expect(s => s.EndBeforeAnchor).Return(fEndBeforeAnchor);
     m_site.ScrollPosition = scrollPos;
 }
        public void FormatApplyStyle_DisabledWhenSelectionIsUneditable()
        {
            SelectionHelper mockedSelectionHelper = MockRepository.GenerateMock <SelectionHelper>();
            IVwSelection    mockedSelection       = MockRepository.GenerateStub <IVwSelection>();

            mockedSelection.Expect(sel => sel.IsEditable).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);
        }
Exemplo n.º 3
0
        public void Setup()
        {
            m_site = new DummyRootSite();

            var rootb = MockRepository.GenerateMock <IVwRootBox>();

            rootb.Expect(rb => rb.Height).Return(10000);
            rootb.Expect(rb => rb.Width).Return(m_site.ClientRectangle.X);
            rootb.Expect(rb => rb.IsPropChangedInProgress).Return(false);

            m_site.RootBox = rootb;

            m_selection = MockRepository.GenerateMock <IVwSelection>();
            m_selection.Expect(s => s.IsValid).Return(true);
            m_site.CreateControl();
            m_site.ScrollMinSize = new Size(m_site.ClientRectangle.Width, 10000);
        }
        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();
        }