AssignMacrosToSlots() private méthode

private AssignMacrosToSlots ( List macroImplementors ) : IFlexMacro[]
macroImplementors List
Résultat IFlexMacro[]
		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 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.
		}
Exemple #3
0
        /// <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);
        }
Exemple #4
0
        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.
		}
Exemple #6
0
        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.
        }
		/// <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;
		}