public void NoArgumentMethod()
        {
            MethodInfo mi = typeof(HelloWorld).GetMethod("NoArgument");
            MethodRunInvoker invoker = new MethodRunInvoker(new MockRun(), mi);
            HelloWorld hw = new HelloWorld();
            invoker.Execute(hw,new ArrayList());

            Assert.IsTrue(hw.Executed);
        }
        public void CallTwoTimes()
        {
            MethodInfo mi = typeof(MethodRepeatWatcher).GetMethod("CallMe");
            MethodRunInvoker methodRun = new MethodRunInvoker(new MockRun(), mi);
            ThreadedRepeatRunInvoker invoker = new ThreadedRepeatRunInvoker(methodRun, 2);

            MethodRepeatWatcher watcher = new MethodRepeatWatcher();
            invoker.Execute(watcher, new ArrayList());

            Assert.AreEqual(2, watcher.count);
        }
        public void OneArgumentMethod()
        {
            MethodInfo mi = typeof(HelloWorld).GetMethod("OneArgument");
            MethodRunInvoker invoker = new MethodRunInvoker(new MockRun(), mi);
            HelloWorld hw = new HelloWorld();

            ArrayList args = new ArrayList();
            args.Add("Hello");
            invoker.Execute(hw,args);

            Assert.IsTrue(hw.Executed);
            Assert.AreEqual(args[0], hw.Arg);
        }
            public override void Reflect(
                RunInvokerTree tree, 
                RunInvokerVertex parent, 
                Type t)
            {
                foreach (MethodInfo method in t.GetMethods())
                {
                    if (method.IsSpecialName)
                        continue;
                    if (!method.Name.EndsWith(this.methodNameSuffix))
                        continue;

                    MethodRunInvoker invoker = new MethodRunInvoker(this, method);
                    IRunInvoker decoratedInvoker = DecoratorPatternAttribute.DecoreInvoker(method, invoker);
                    tree.AddChild(parent, decoratedInvoker);
                }
            }
 public override void Reflect(RunInvokerTree tree, RunInvokerVertex parent, Type t)
 {
     MethodInfo method = t.GetMethod(this.methodName, Type.EmptyTypes);
     if (method == null)
         return;
     MethodRunInvoker invoker = new MethodRunInvoker(this, method);
     IRunInvoker decoratedInvoker = DecoratorPatternAttribute.DecoreInvoker(method, invoker);
     tree.AddChild(parent, decoratedInvoker);
 }
 public void MethodNull()
 {
     MethodRunInvoker invoker = new MethodRunInvoker(new MockRun(), null);
 }
        private IRunInvoker InstanceInvoker(MethodInfo mi)
        {
            IRunInvoker invoker = new MethodRunInvoker(this,mi);

            return DecoratorPatternAttribute.DecoreInvoker(mi,invoker);
        }
 protected IRunInvoker InstanceCriticalStepInvoker(MethodInfo mi)
 {
     IRunInvoker invoker = new MethodRunInvoker(this,mi);
     return DecoratorPatternAttribute.DecoreInvoker(mi,invoker);
 }
 private IRunInvoker InstanceTesterInvoker(MethodInfo mi)
 {
     IRunInvoker invoker = new MethodRunInvoker(this,mi);
     return invoker;
 }
Beispiel #10
0
		private void PopulateInvokerTree(
			RunInvokerTree tree, 
			RunInvokerVertex parent, 
			Type t
			)
		{
            // Try and find setup method
            MethodRunInvoker setup = null;
            if (TypeHelper.HasMethodCustomAttribute(t, typeof(SetUpAttribute)))
            {
                setup = new MethodRunInvoker(this, TypeHelper.GetAttributedMethod(t, typeof(SetUpAttribute)));
            }

			// Gather all methods, with order.
			ArrayList methods = new ArrayList();
			foreach(MethodInfo mi in 
					TypeHelper.GetAttributedMethods(t,this.AttributeType))
			{
				// get sequence attribute
				TestSequenceAttribute seq = 
					(TestSequenceAttribute)TypeHelper.GetFirstCustomAttribute(mi,typeof(TestSequenceAttribute)); 
				methods.Add( new OrderedMethod(mi, seq.Order) );		
			}
			
			// sort the methods
			QuickSorter sorter = new QuickSorter();
			sorter.Sort(methods);

            // Try and find teardown method
            MethodRunInvoker teardown = null;
            if (TypeHelper.HasMethodCustomAttribute(t, typeof(TearDownAttribute)))
            {
                teardown = new MethodRunInvoker(this, TypeHelper.GetAttributedMethod(t, typeof(TearDownAttribute)));
            }

			// populate execution tree.
			RunInvokerVertex child = parent;
			foreach(OrderedMethod om in methods)
			{
                if (setup != null)
                    child = tree.AddChild(child, setup);

				child = tree.AddChild(child, InstanceInvoker(om.Method));

                if (teardown != null)
                    child = tree.AddChild(child, teardown);
			}				
		}