private void Visit(TestTreeNode node, string tab)
 {
     Console.WriteLine("{0}{1}",tab,node.Name);
     string tabchild = tab + "  ";
     foreach (TestTreeNode child in node.Nodes)
         Visit(child, tabchild);
 }
示例#2
0
 public override void Clear()
 {
     this.parentNode = null;
     this.anonymous = null;
     this.testedTypeNodes.Clear();
     this.fixtureNodes.Clear();
 }
 public override void Clear()
 {
     this.parentNode = null;
     this.anonymous = null;
     this.importanceNodes.Clear();
     this.fixtureNodes.Clear();
 }
		/// <summary>
		/// Populates the node using the <see cref="RunPipe"/> instance
		/// contained in <paramref name="pipes"/>.
		/// </summary>
		public override void Populate(
			GuidTestTreeNodeDictionary nodes, 
			TestTreeNode rootNode, RunPipeStarterCollection pipes)
		{
			if (rootNode==null)
				throw new ArgumentNullException("rootNode");
			if (pipes==null)
				throw new ArgumentNullException("pipes");

            if (this.parentNode == null)
            {
                this.parentNode = new TestTreeNode("Namespaces", TestNodeType.Populator);
                rootNode.Nodes.Add(this.parentNode);
                nodes.Add(this.parentNode);
            }

            foreach(RunPipeStarter pipeStarter in pipes)
			{
				TestTreeNode namespaceNode = this.addNamespaceNodes(nodes,pipeStarter);

				// get fixture name
				TestTreeNode fixtureNode = this.addFixtureNode(nodes,namespaceNode,pipeStarter);

				CreatePipeNode(nodes,fixtureNode,pipeStarter);
			}
		}
        public override void Populate(
            GuidTestTreeNodeDictionary nodes,
            TestTreeNode root,
            RunPipeStarterCollection pipes)
        {
            if (this.parentNode == null)
            {
                this.parentNode = new TestTreeNode("Categories", TestNodeType.Populator);
                root.Nodes.Add(this.parentNode);
                nodes.Add(this.parentNode);
                this.miscNode = this.addCategoryNodes(nodes, "Misc");
            }

            foreach(RunPipeStarter starter in pipes)
            {
                if (TypeHelper.HasCustomAttribute(
                    starter.Pipe.FixtureType,
                    typeof(FixtureCategoryAttribute)
                    ))
                {
                    foreach(TestTreeNode categoryNode in
                        this.categoryNodesFrom(nodes,starter.Pipe.FixtureType))
                    {
                        TestTreeNode fixtureNode = addFixtureNode(nodes,categoryNode,starter);
                        CreatePipeNode(nodes,fixtureNode,starter);
                    }
                }
                else
                {
                    TestTreeNode fixtureNode = addFixtureNode(nodes,this.miscNode,starter);
                    CreatePipeNode(nodes,fixtureNode,starter);
                }
            }
        }
 public override void Clear()
 {
     this.categoryNodes.Clear();
     this.parentNode=null;
     this.miscNode = null;
     this.fixtureNodes.Clear();
 }
        public void Test()
        {
            this.target = new FixtureCategoryTestTreePopulator();
            this.dic = new GuidTestTreeNodeDictionary();

            root = new TestTreeNode("root", TestNodeType.Category);

            AddPipe(typeof(MbUnit.Core.Remoting.DummyClass1));
            AddPipe(typeof(MbUnit.Core.Remoting.DummyClass2));

            Visit(root,"");

            Assert.AreEqual(1, root.Nodes.Count);

            TestTreeNode categories = root.Nodes[0];
            Assert.AreEqual("Categories", categories.Name);
            Assert.AreEqual(3, categories.Nodes.Count);

            foreach (TestTreeNode node in categories.Nodes)
            {
                Assert.AreEqual(1, node.Nodes.Count);
                switch (node.Name)
                {
                    case "Misc":
                        {
                            TestTreeNode dummyNode2 = node.Nodes[0];
                            Assert.AreEqual(1, dummyNode2.Nodes.Count);
                            Assert.AreEqual("DummyClass2", dummyNode2.Name);

                            break;
                        }

                    case "MyApp":
                        {
                            TestTreeNode businessLogic = node.Nodes[0];
                            Assert.AreEqual(1, businessLogic.Nodes.Count);
                            Assert.AreEqual("BusinessLogic", businessLogic.Name);

                            TestTreeNode dummyNode1 = businessLogic.Nodes[0];
                            Assert.AreEqual(1, dummyNode1.Nodes.Count);
                            Assert.AreEqual("DummyClass1", dummyNode1.Name);

                            break;
                        }

                    case "BusinessLogic":
                        {
                            TestTreeNode dummyNode1 = node.Nodes[0];
                            Assert.AreEqual(1, dummyNode1.Nodes.Count);
                            Assert.AreEqual("DummyClass1", dummyNode1.Name);

                            break;
                        }
                }
            }
        }
示例#8
0
        public override void Dispose()
        {
            base.Dispose();

            this.facade.Clear();
            this.facade = null;
            this.guidNodes = null;
            this.populators = null;
            this.parentNode = null;
        }
		private TestTreeNode addFixtureNode(GuidTestTreeNodeDictionary nodes, 
			TestTreeNode parentNode,
			RunPipeStarter pipeStarter)
		{
			RunPipe pipe = pipeStarter.Pipe;
            TestTreeNode fixtureNode = this.fixtureNodes[pipe.Fixture.Type] as TestTreeNode;
            if (fixtureNode != null)
                return fixtureNode;

            fixtureNode = new TestTreeNode(pipe.FixtureName,TestNodeType.Fixture);
			this.fixtureNodes.Add(pipe.Fixture.Type,fixtureNode);
			nodes.Add(fixtureNode);
			parentNode.Nodes.Add(fixtureNode);

            return fixtureNode;
        }
 public static TestTreeNode CreatePipeNode(
     GuidTestTreeNodeDictionary nodes,
     TestTreeNode parentNode, RunPipeStarter starter)
 {
     TestTreeNode pipeNode = new TestTreeNode(starter.Pipe.ShortName,TestNodeType.Test);
     pipeNode.Starter = starter;
     pipeNode.State = TestState.NotRun;
     nodes.Add(pipeNode);
     parentNode.Nodes.Add(pipeNode);
     /*
     foreach (RunInvokerVertex v in starter.Pipe.Invokers)
     {
         TestTreeNode invokerNode = new TestTreeNode(v.Invoker.Name,TestNodeType.Invoker);
         pipeNode.Nodes.Add(invokerNode);
     }
     */
     return pipeNode;
 }
        public override void Populate(
            GuidTestTreeNodeDictionary nodes,
            TestTreeNode rootNode,
            RunPipeStarterCollection pipes
            )
        {
            if (rootNode==null)
                throw new ArgumentNullException("rootNode");
            if (pipes==null)
                throw new ArgumentNullException("pipes");

            if (this.parentNode == null)
            {
                this.parentNode = new TestTreeNode("Importances", TestNodeType.Populator);
                rootNode.Nodes.Add(this.parentNode);
                nodes.Add(this.parentNode);
                // adding nodes
                foreach (TestImportance ti in Enum.GetValues(typeof(TestImportance)))
                {
                    this.addImportance(nodes, ti);
                }
                // add unknown Importance
                anonymous = this.addImportance(nodes, TestImportance.Default);
            }

            foreach(RunPipeStarter pipeStarter in pipes)
            {
                // get Importance attribute
                TestTreeNode node = null;
                if (TypeHelper.HasCustomAttribute(pipeStarter.Pipe.FixtureType,typeof(ImportanceAttribute)))
                {
                    ImportanceAttribute Importance = (ImportanceAttribute)TypeHelper.GetFirstCustomAttribute(
                        pipeStarter.Pipe.FixtureType,typeof(ImportanceAttribute));

                    node = addImportance(nodes,Importance.Importance);
                }
                else
                    node = anonymous;

                TestTreeNode fixtureNode = addFixtureNode(nodes,node,pipeStarter);
                CreatePipeNode(nodes,fixtureNode,pipeStarter);
            }
        }
示例#12
0
        protected void CreateTree(UnitTreeNode node, TestTreeNodeFacade facade, TestTreeNode testNode)
        {
            if (testNode.IsTest)
            {
                facade.AddNode(testNode.PipeIdentifier, node);
            }

            foreach (TestTreeNode childNode in testNode.Nodes)
            {
                UnitTreeNode cnode = this.factory.CreateUnitTreeNode(
                    childNode.Name,
                    childNode.NodeType,
                    this.Identifier,
                    childNode.Identifier
                    );
                this.factory.AddChildUnitTreeNode(node, cnode);
                this.CreateTree(cnode, facade, childNode);
            }
        }
        public void Test()
        {
            this.target = new NamespaceTestTreePopulator();
            this.dic = new GuidTestTreeNodeDictionary();

            root = new TestTreeNode("root", TestNodeType.Category);

            AddPipe(typeof(MbUnit.Core.Remoting.Child1.DummyClass));
            AddPipe(typeof(MbUnit.Core.Remoting.Child2.DummyClass));

            Visit(root,"");

            Assert.AreEqual(1, root.Nodes.Count);

            TestTreeNode child = root.Nodes[0];
            Assert.AreEqual("Namespaces", child.Name);
            Assert.AreEqual(1, child.Nodes.Count);

            child = child.Nodes[0];
            Assert.AreEqual(1, child.Nodes.Count);
            Assert.AreEqual("MbUnit", child.Name);

            child = child.Nodes[0];
            Assert.AreEqual(1, child.Nodes.Count);
            Assert.AreEqual("Core", child.Name);

            child = child.Nodes[0];
            Assert.AreEqual("Remoting", child.Name);

            Assert.AreEqual(2, child.Nodes.Count);
            Assert.IsTrue((child.Nodes[0].Name == "Child1" && child.Nodes[1].Name == "Child2")
                || (child.Nodes[0].Name == "Child2" && child.Nodes[1].Name == "Child1")
                );

            Assert.AreEqual(1,child.Nodes[0].Nodes.Count);
            Assert.AreEqual(1,child.Nodes[1].Nodes.Count);
            Assert.AreEqual("DummyClass", child.Nodes[0].Nodes[0].Name);
            Assert.AreEqual("DummyClass", child.Nodes[1].Nodes[0].Name);
        }
示例#14
0
		public override void Populate(
			GuidTestTreeNodeDictionary nodes, 
			TestTreeNode rootNode, 
			MbUnit.Core.Collections.RunPipeStarterCollection pipes
			)
		{
			if (rootNode==null)
				throw new ArgumentNullException("rootNode");
			if (pipes==null)
				throw new ArgumentNullException("pipes");

            if (this.parentNode == null)
            {
                this.parentNode = new TestTreeNode("Authors", TestNodeType.Populator);
                nodes.Add(this.parentNode);
                rootNode.Nodes.Add(this.parentNode);
                // add unknown author
                this.anonymous = this.addAuthor(nodes, "Anonymous");
            }

            foreach(RunPipeStarter pipeStarter in pipes)
			{
				// get author attribute
				TestTreeNode node = null;
                AuthorAttribute author = (AuthorAttribute)TypeHelper.TryGetFirstCustomAttribute(
                        pipeStarter.Pipe.FixtureType, typeof(AuthorAttribute));
                if (author!=null)
                	node = addAuthor(nodes,author.Name);
				else
					node = anonymous;

				TestTreeNode fixtureNode = addFixtureNode(nodes,node,pipeStarter);

				CreatePipeNode(nodes,fixtureNode,pipeStarter);
			}
		}
 /// <summary>
 /// Adds an element with the specified key and value to this StringTestTreeNodeDictionary.
 /// </summary>
 /// <param name="key">
 /// The String key of the element to add.
 /// </param>
 /// <param name="value">
 /// The TestTreeNode value of the element to add.
 /// </param>
 public virtual void Add(String key, TestTreeNode value)
 {
     this.Dictionary.Add(key, value);
 }
		/// <summary>
		/// Clears the internal representation of the tree
		/// </summary>
		public override void Clear()
		{
			this.parentNode = null;
			this.namespaceNodes.Clear();	
			this.fixtureNodes.Clear();
		}
 /// <summary>
 /// Populates the node using the <see cref="RunPipe"/> instance
 /// contained in <paramref name="pipes"/>.
 /// </summary>
 /// <exception cref="ArgumentNullException">
 /// <param name="root"/> or <paramref name="pipes"/> is a null
 /// reference (Nothing in Visual Basic)
 /// </exception>
 public abstract void Populate(GuidTestTreeNodeDictionary nodes, TestTreeNode root, RunPipeStarterCollection pipes);
        protected override void LoadPipes()
        {
            base.LoadPipes();

            this.guidNodes.Clear();

            // create nodes
            AssemblyName assemblyName = this.TestAssembly.GetName();
            string name = String.Format("{0} {1}.{2}", assemblyName.Name, assemblyName.Version.Major, assemblyName.Version.Minor);
            this.parentNode = new TestTreeNode(name, TestNodeType.Populator);
            this.guidNodes.Add(this.parentNode);

            // populate
            foreach (TestTreePopulator pop in this.populators)
            {
                pop.Clear();
                foreach (Fixture fixture in this.Explorer.FixtureGraph.Fixtures)
                {
                    if (fixture.Starters.Count > 0)
                    {
                        pop.Populate(this.guidNodes, parentNode, fixture.Starters);
                    }
                }
            }
        }
 /// <summary>
 /// Adds an element with the specified key and value to this GuidTestTreeNodeDictionary.
 /// </summary>
 /// <param name="value">
 /// The TestTreeNode value of the element to add.
 /// </param>
 public virtual void Add(TestTreeNode value)
 {
     this.Dictionary.Add(value.Identifier, value);
 }
 private void GetSelectedNodes(TestTreeNode testNode)
 {
     if (testNode.Starter != null)
     {
         this.selectedPipes[testNode.Starter]=null;
         this.selectedFixtures[testNode.Starter.Pipe.Fixture] = null;
     }
     foreach (TestTreeNode child in testNode.Nodes)
     {
         GetSelectedNodes(child);
     }
 }
 /// <summary>
 /// Initializes a new empty instance of the TestTreeNodeCollection class.
 /// </summary>
 public TestTreeNodeCollection( TestTreeNode owner)
 {
     this.owner = new WeakReference(owner);
 }
 private TestTreeNode addImportance(
     GuidTestTreeNodeDictionary nodes,
     TestImportance importance)
 {
     TestTreeNode node = this.importanceNodes[importance.ToString()];
     if (node==null)
     {
         node = new TestTreeNode(importance.ToString(),TestNodeType.Category);
         this.parentNode.Nodes.Add(node);
         this.importanceNodes.Add(importance.ToString(),node);
         nodes.Add(node);
     }
     return node;
 }
 private TestTreeNode addFixtureNode(GuidTestTreeNodeDictionary nodes, 
     TestTreeNode parentNode,
     RunPipeStarter pipeStarter)
 {
     RunPipe pipe = pipeStarter.Pipe;
     string key=pipe.FixtureName+parentNode.Name;
     if (!this.fixtureNodes.Contains(key))
     {
         TestTreeNode  fixtureNode = new TestTreeNode(pipe.FixtureName,TestNodeType.Fixture);
         this.fixtureNodes.Add(key,fixtureNode);
         nodes.Add(fixtureNode);
         parentNode.Nodes.Add(fixtureNode);
     }
     return (TestTreeNode)this.fixtureNodes[key];
 }
示例#24
0
		private TestTreeNode addAuthor(
			GuidTestTreeNodeDictionary nodes, 
			string name)
		{
			TestTreeNode node = this.authorNodes[name];
			if (node==null)
			{
				node = new TestTreeNode(name,TestNodeType.Category);
				this.parentNode.Nodes.Add(node);
				nodes.Add(node);
				this.authorNodes.Add(name,node);
			}
			return node;
		}
 /// <summary>
 /// Adds an instance of type TestTreeNode to the end of this TestTreeNodeCollection.
 /// </summary>
 /// <param name="value">
 /// The TestTreeNode to be added to the end of this TestTreeNodeCollection.
 /// </param>
 public virtual void Add(TestTreeNode value)
 {
     value.Parent = (TestTreeNode)this.owner.Target;
     this.List.Add(value);
 }
 /// <summary>
 /// Determines whether a specfic TestTreeNode value is in this TestTreeNodeCollection.
 /// </summary>
 /// <param name="value">
 /// The TestTreeNode value to locate in this TestTreeNodeCollection.
 /// </param>
 /// <returns>
 /// true if value is found in this TestTreeNodeCollection;
 /// false otherwise.
 /// </returns>
 public virtual bool Contains(TestTreeNode value)
 {
     return this.List.Contains(value);
 }
示例#27
0
 private TestTreeNode addTestsOn(
     GuidTestTreeNodeDictionary nodes,
     string testedTypeFullName)
 {
     TestTreeNode node = this.testedTypeNodes[testedTypeFullName];
     if (node == null)
     {
         node = new TestTreeNode(testedTypeFullName, TestNodeType.Category);
         this.parentNode.Nodes.Add(node);
         nodes.Add(node);
         this.testedTypeNodes.Add(testedTypeFullName, node);
     }
     return node;
 }
 public override void Clear()
 {
     this.parentNode=null;
     if (this.facade!=null)
         this.facade.Clear();
     if (this.populators!=null)
         this.populators.Clear();
     if (this.guidNodes!=null)
         this.guidNodes.Clear();
 }
		private TestTreeNode addNamespaceNodes(GuidTestTreeNodeDictionary nodes, RunPipeStarter pipeStarter)
		{
			RunPipe pipe = pipeStarter.Pipe;
			string ns = "";
			
			TestTreeNode parent = this.parentNode;
			string namespace_ = pipe.FixtureType.Namespace;
			if (namespace_==null ||namespace_.Length==0)
				namespace_="";
			foreach(string name in namespace_.Split('.'))
			{
				if (ns.Length==0)
					ns+=name;
				else
					ns+="."+name;

				if (!this.namespaceNodes.Contains(ns))
				{
					TestTreeNode  node = new TestTreeNode(name,TestNodeType.Category);

					this.namespaceNodes.Add(ns,node);
					parent.Nodes.Add(node);
					nodes.Add(node);
					parent = node;
				}
				else
					parent = (TestTreeNode)this.namespaceNodes[ns];	
			}
			
			return parent;
		}	
 /// <summary>
 /// Removes the first occurrence of a specific TestTreeNode from this TestTreeNodeCollection.
 /// </summary>
 /// <param name="value">
 /// The TestTreeNode value to remove from this TestTreeNodeCollection.
 /// </param>
 public virtual void Remove(TestTreeNode value)
 {
     value.Parent = null;
     this.List.Remove(value);
 }