public void SafeToDoMacro_WithNoSelection_ReturnsFalse() { var ml = new MacroListener(); int ichA, hvoA, flid, ws, ichE, start, length; ICmObject obj; Assert.That(ml.SafeToDoMacro(null, out obj, out flid, out ws, out start, out length), Is.False); }
public void InitMacro_PutsItemAtProperPosition() { var ml = new MacroListener(); var macroImplementors = new List<IFlexMacro>(new IFlexMacro[] {new MacroF4()}); var macros = ml.AssignMacrosToSlots(macroImplementors); Assert.That(macros[0], Is.Null); Assert.That(macros[2], Is.EqualTo(macroImplementors[0])); }
public void DoDisplayMacro_NoMacro_HidesCommand() { var props = new UIItemDisplayProperties(null, "SomeMacro", true, null, false); var ml = new MacroListener(); var command = GetF4CommandObject(); ml.DoDisplayMacro(command, props, null); Assert.That(props.Visible, Is.False); // no implementation of F4, hide it altogether. }
public void InitMacro_PutsConflictAtFirstAvailableSpot() { var ml = new MacroListener(); var macroImplementors = new List<IFlexMacro>(new IFlexMacro[] { new MacroF4(), new MacroF4(), new MacroF2() }); var macros = ml.AssignMacrosToSlots(macroImplementors); Assert.That(macros[0], Is.EqualTo(macroImplementors[2])); // the only one that wants to be at F2 Assert.That(macros[2], Is.EqualTo(macroImplementors[0])); // first one that wants to be a F4 Assert.That(macros[1], Is.EqualTo(macroImplementors[1])); // can't put where it wants to be, put it in first free slot. }
/// <summary> /// Initialize the listener into a state where there is a MacroF4 mock available to implement that command. /// </summary> /// <param name="ml"></param> /// <returns></returns> private static MacroF4 SetupF4Implementation(MacroListener ml) { var macroF4 = new MacroF4(); var macroImplementors = new List <IFlexMacro>(new IFlexMacro[] { macroF4 }); ml.Macros = ml.AssignMacrosToSlots(macroImplementors); macroF4.BeEnabled = true; return(macroF4); }
private MacroListener MakeMacroListenerWithCache() { m_Mediator = new Mediator(); m_Mediator.PropertyTable.SetProperty("cache", Cache); var ml = new MacroListener(); ml.Init(m_Mediator, null); return(ml); }
[Test] public void InitMacro_PutsItemAtProperPosition() { var ml = new MacroListener(); var macroImplementors = new List <IFlexMacro>(new IFlexMacro[] { new MacroF4() }); var macros = ml.AssignMacrosToSlots(macroImplementors); Assert.That(macros[0], Is.Null); Assert.That(macros[2], Is.EqualTo(macroImplementors[0])); }
private MacroListener MakeMacroListenerWithCache() { m_mediator = new Mediator(); m_propertyTable = new PropertyTable(m_mediator); m_propertyTable.SetProperty("cache", Cache, true); var ml = new MacroListener(); ml.Init(m_mediator, m_propertyTable, null); return(ml); }
public void DoDisplayMacro_NoMacro_HidesCommand() { var props = new UIItemDisplayProperties(null, "SomeMacro", true, null, false); var ml = new MacroListener(); using (var command = GetF4CommandObject()) { ml.DoDisplayMacro(command, props, null); Assert.That(props.Visible, Is.False); // no implementation of F4, hide it altogether. } }
public void InitMacro_PutsConflictAtFirstAvailableSpot() { var ml = new MacroListener(); var macroImplementors = new List <IFlexMacro>(new IFlexMacro[] { new MacroF4(), new MacroF4(), new MacroF2() }); var macros = ml.AssignMacrosToSlots(macroImplementors); Assert.That(macros[0], Is.EqualTo(macroImplementors[2])); // the only one that wants to be at F2 Assert.That(macros[2], Is.EqualTo(macroImplementors[0])); // first one that wants to be a F4 Assert.That(macros[1], Is.EqualTo(macroImplementors[1])); // can't put where it wants to be, put it in first free slot. }
public void InitMacro_SurvivesTooManyMacros() { var ml = new MacroListener(); var macroImplementors = new List<IFlexMacro>(); for (int i = 0; i < 20; i++) macroImplementors.Add(new MacroF4()); var macros = ml.AssignMacrosToSlots(macroImplementors); Assert.That(macros[0], Is.EqualTo(macroImplementors[1])); // first free slot gets the second one Assert.That(macros[2], Is.EqualTo(macroImplementors[0])); // first one that wants to be a F4 Assert.That(macros[1], Is.EqualTo(macroImplementors[2])); // can't put where it wants to be, put it in next free slot. Assert.That(macros[3], Is.EqualTo(macroImplementors[3])); // from here on they line up. }
public void DoDisplayMacro_NoSelection_ShowsDisabledCommand() { var props = new UIItemDisplayProperties(null, "SomeMacro", true, null, false); var ml = new MacroListener(); SetupF4Implementation(ml); var command = GetF4CommandObject(); ml.DoDisplayMacro(command, props, null); Assert.That(props.Visible, Is.True); Assert.That(props.Enabled, Is.False); // can't do it without a selection Assert.That(props.Text, Is.EqualTo("F4test")); }
public void DoDisplayMacro_NoSelection_ShowsDisabledCommand() { var props = new UIItemDisplayProperties(null, "SomeMacro", true, null, false); var ml = new MacroListener(); SetupF4Implementation(ml); using (var command = GetF4CommandObject()) { ml.DoDisplayMacro(command, props, null); Assert.That(props.Visible, Is.True); Assert.That(props.Enabled, Is.False); // can't do it without a selection Assert.That(props.Text, Is.EqualTo("F4test")); } }
public void InitMacro_SurvivesTooManyMacros() { var ml = new MacroListener(); var macroImplementors = new List <IFlexMacro>(); for (int i = 0; i < 20; i++) { macroImplementors.Add(new MacroF4()); } var macros = ml.AssignMacrosToSlots(macroImplementors); Assert.That(macros[0], Is.EqualTo(macroImplementors[1])); // first free slot gets the second one Assert.That(macros[2], Is.EqualTo(macroImplementors[0])); // first one that wants to be a F4 Assert.That(macros[1], Is.EqualTo(macroImplementors[2])); // can't put where it wants to be, put it in next free slot. Assert.That(macros[3], Is.EqualTo(macroImplementors[3])); // from here on they line up. }
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 }
private MacroListener MakeMacroListenerWithCache() { m_Mediator = new Mediator(); m_Mediator.PropertyTable.SetProperty("cache", Cache); var ml = new MacroListener(); ml.Init(m_Mediator, null); return ml; }
/// <summary> /// Initialize the listener into a state where there is a MacroF4 mock available to implement that command. /// </summary> /// <param name="ml"></param> /// <returns></returns> private static MacroF4 SetupF4Implementation(MacroListener ml) { var macroF4 = new MacroF4(); var macroImplementors = new List<IFlexMacro>(new IFlexMacro[] {macroF4}); ml.Macros = ml.AssignMacrosToSlots(macroImplementors); macroF4.BeEnabled = true; return macroF4; }