private void PopulateInvokerTree(
            RunInvokerTree tree,
            RunInvokerVertex parent,
            Type t
            )
        {
            // first 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);

            // populate execution tree.
            RunInvokerVertex child = parent;
            foreach(OrderedMethod om in methods)
            {
                IRunInvoker invoker = InstanceInvoker(om.Method);
                child = tree.AddChild(child,invoker);
            }
        }
 //    return adjacent vertices to "v" sorted in topological order
 private ArrayList TopoSortAdjVertices( IVertex v, IIncidenceGraph g, VertexIntDictionary topo_ordering )
 {
     IEdgeEnumerator it = g.OutEdges(v).GetEnumerator();
     bool valid = false;
     ArrayList adj = new ArrayList();
     while(it.MoveNext())	{
         valid = true;
         adj.Add(it.Current.Target);
     }
     if(!valid)		// no outgoing edges
         return adj;
     CompareTopo ctopo = new CompareTopo(topo_ordering);
     SwapTopo stopo = new SwapTopo();
     QuickSorter qs = new QuickSorter(ctopo, stopo);
     qs.Sort(adj);
     return adj;
 }
예제 #3
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);
			}				
		}