public void FindNode_NodeThere_ReturnsTheNode()
 {
   TreeNode node = new TreeNode("AnotherNode");
   _service.PushNode(node);
   _service.PopNode();
   Assert.AreEqual(node, _service.FindNode("AnotherNode"));
 }
 public void PopNode_NotUnderRoot_PopsTopNode()
 {
   TreeNode node = new TreeNode("AnotherNode");
   _service.PushNode(node);
   Assert.AreEqual(node, _service.Peek);
   _service.PopNode();
   Assert.AreNotEqual(node, _service.Peek);
 }
예제 #3
0
		public void AddChild(TreeNode node, bool force)
		{
			if (!force && Children.Contains(node))
				return;
			
			node.Parent = this;
			Children.Add(node);
		}
 public void PushNode_Always_AddsChildAndSetsCurrent()
 {
   TreeNode node = new TreeNode("AnotherNode");
   _service.PushNode(node);
   Assert.Contains(node, _service.Root.Children);
   Assert.AreEqual(_service.Root, node.Parent);
   Assert.AreEqual(node, _service.Peek);
 }
예제 #5
0
		public virtual void Accept(TreeNode node)
		{
			Type type = node.GetType();
			MethodInfo method = GetType().GetMethod("Visit", new Type[] {type});
			if (method != null)
			{
				method.Invoke(this, new object[] { node });
			}
		}
    public void Execute_WithEvaluatedItems_Works()
    {
      TreeNode root = new TreeNode("Root");

      File.CreateText(@"CoolSuperSourceCode.cs").Close();

      using (_mocks.Unordered())
      {
        _buildEngine.LogMessageEvent(null);
        LastCall.IgnoreArguments().Repeat.Any();        
      	Expect.Call(_item.GetMetadata("FullPath")).Return("CoolSuperSourceCode.cs").Repeat.Any();
        _parserService.Parse(null, null);
        LastCall.Constraints(Is.NotNull(), Is.Equal("CoolSuperSourceCode.cs"));
        Expect.Call(_treeService.Root).Return(root).Repeat.Any();
        _generator.Generate(root);
        Expect.Call(_source.Ccu).Return(_ccu).Repeat.Any();
      }

      _task.BuildEngine = _buildEngine;
      _task.Sources = new ITaskItem[] { _item };
      _task.ControllerSources = new ITaskItem[0];
      _task.ViewSources = new ITaskItem[0];
      _task.Namespace = "Eleutian.Empty";
      _task.OutputFile = "SiteMap.generated.cs";

      _mocks.ReplayAll();
      Assert.IsTrue(_task.Execute());
      Assert.AreEqual("SiteMap.generated.cs", _task.GeneratedItems[0].ItemSpec);

      File.Delete(_task.OutputFile);
    }
    public void Execute_OneViewSource_ReturnsTrue()
    {
      TreeNode root = new TreeNode("Root");
      using (_mocks.Unordered())
      {
        _buildEngine.LogMessageEvent(null);
        LastCall.IgnoreArguments().Repeat.Any();       
      	Expect.Call(_item.GetMetadata("FullPath")).Return("Index.brail").Repeat.Any();
        _viewSourceMapper.AddViewSource("Index.brail");
        Expect.Call(_treeService.Root).Return(root).Repeat.Any();
        _generator.Generate(root);
        Expect.Call(_source.Ccu).Return(_ccu).Repeat.Any();
      }

      _task.BuildEngine = _buildEngine;
      _task.Sources = new ITaskItem[0];
      _task.ControllerSources = new ITaskItem[0];
      _task.ViewSources = new ITaskItem[] { _item };
      _task.Namespace = "Eleutian.Empty";
      _task.OutputFile = "SiteMap.generated.cs";

      _mocks.ReplayAll();
      Assert.IsTrue(_task.Execute());
      Assert.AreEqual("SiteMap.generated.cs", _task.GeneratedItems[0].ItemSpec);

      File.Delete(_task.OutputFile);
    }
예제 #8
0
		public void AddChild(TreeNode node)
		{
			AddChild(node, false);
		}
 public void PushNode(TreeNode node)
 {
   _nodes.Peek().AddChild(node);
   _nodes.Push(node);
 }
 public DefaultTreeCreationService()
 {
   _root = new AreaTreeNode("Root");
   _nodes.Push(_root);
 }
예제 #11
0
		public void Generate(TreeNode root)
		{
			Accept(root);
		} 
예제 #12
0
 public void GetHashCode_WhenDifferent_NotEqual()
 {
   TreeNode node1 = new TreeNode("Node1");
   TreeNode node2 = new TreeNode("Node2");
   Assert.AreNotEqual(node1.GetHashCode(), node2.GetHashCode());
 }
예제 #13
0
 public void GetHashCode_WhenSame_Equal()
 {
   TreeNode node1 = new TreeNode("Node1");
   TreeNode node2 = new TreeNode("Node1");
   Assert.AreEqual(node1.GetHashCode(), node2.GetHashCode());
 }