This class mocks the (unfortunately huge) IVwSelection. Only the first couple of methods are actually used by MacroListener, others are left unimplemented. Enhance JohnT: this would be better done with some sort of dynamic mock, so that changes to parts of the interface we don't care about won't have to be made here. But we haven't settled on a mock framework for FLEx.
Inheritance: IVwSelection
コード例 #1
0
        private static MockSelection GetValidMockSelection(ILexEntry entry)
        {
            var sel = new MockSelection();

            sel.TypeToReturn = VwSelType.kstText;
            sel.EndHvo       = sel.AnchorHvo = entry.Hvo;
            sel.EndTag       = sel.AnchorTag = LexEntryTags.kflidRestrictions;       // arbitrary in this case
            sel.EndIch       = 2;
            sel.AnchorIch    = 5;
            return(sel);
        }
コード例 #2
0
        public void SafeToDoMacro_WithUnsuitableSelection_ReturnsFalse()
        {
            var ml  = new MacroListener();
            var sel = new MockSelection();

            sel.EndHvo    = sel.AnchorHvo = 317;
            sel.EndTag    = sel.AnchorTag = LexEntryTags.kflidRestrictions;          // arbitrary in this case
            sel.EndIch    = 2;
            sel.AnchorIch = 5;
            int       ichA, hvoA, flid, ws, ichE, start, length;
            ICmObject obj;

            Assert.That(ml.SafeToDoMacro(sel, out obj, out flid, out ws, out start, out length), Is.False);             // wrong type of selection

            sel.TypeToReturn = VwSelType.kstText;
            sel.EndHvo       = 316;
            Assert.That(ml.SafeToDoMacro(sel, out obj, out flid, out ws, out start, out length), Is.False);             // different objects

            sel.EndHvo = sel.AnchorHvo;
            sel.EndTag = 3;
            Assert.That(ml.SafeToDoMacro(sel, out obj, out flid, out ws, out start, out length), Is.False);             // different tags
        }
コード例 #3
0
		public void SafeToDoMacro_WithUnsuitableSelection_ReturnsFalse()
		{
			var ml = new MacroListener();
			var sel = new MockSelection();
			sel.EndHvo = sel.AnchorHvo = 317;
			sel.EndTag = sel.AnchorTag = LexEntryTags.kflidRestrictions; // arbitrary in this case
			sel.EndIch = 2;
			sel.AnchorIch = 5;
			int ichA, hvoA, flid, ws, ichE, start, length;
			ICmObject obj;

			Assert.That(ml.SafeToDoMacro(sel, out obj, out flid, out ws, out start, out length), Is.False); // wrong type of selection

			sel.TypeToReturn = VwSelType.kstText;
			sel.EndHvo = 316;
			Assert.That(ml.SafeToDoMacro(sel, out obj, out flid, out ws, out start, out length), Is.False); // different objects

			sel.EndHvo = sel.AnchorHvo;
			sel.EndTag = 3;
			Assert.That(ml.SafeToDoMacro(sel, out obj, out flid, out ws, out start, out length), Is.False); // different tags
		}
コード例 #4
0
		private static MockSelection GetValidMockSelection(ILexEntry entry)
		{
			var sel = new MockSelection();
			sel.TypeToReturn = VwSelType.kstText;
			sel.EndHvo = sel.AnchorHvo = entry.Hvo;
			sel.EndTag = sel.AnchorTag = LexEntryTags.kflidRestrictions; // arbitrary in this case
			sel.EndIch = 2;
			sel.AnchorIch = 5;
			return sel;
		}