public void RemoveChild() { Task parent = new Task(); Task child_1 = new Task(); Task child_2 = new Task(); parent.AddChild(child_1); parent.AddChild(child_2); parent.RemoveChild(child_1); Assert.That(parent.Children.Count, Is.EqualTo(1)); Assert.That(parent.Children.Contains(child_2)); Assert.That(child_1.Parent, Is.Null); }
public void AddChild() { Task parent = new Task(); Task child_1 = new Task(); parent.AddChild(child_1); Assert.That(child_1.Sequence, Is.EqualTo(1)); Assert.That(parent.Children.Count, Is.EqualTo(1)); Assert.That(parent.Children.Contains(child_1)); Task child_2 = new Task(); parent.AddChild(child_2); Assert.That(child_2.Sequence, Is.EqualTo(2)); Assert.That(parent.Children.Count, Is.EqualTo(2)); Assert.That(parent.Children.Contains(child_1)); Assert.That(parent.Children.Contains(child_2)); }
public void Remove_And_Add_Child() { Task parent = new Task(); Task child_1 = new Task(); Task child_2 = new Task(); parent.AddChild(child_1); parent.AddChild(child_2); parent.RemoveChild(child_1); parent.AddChild(child_1); Assert.That(parent.Children.Count, Is.EqualTo(2)); Assert.That(parent.Children.Contains(child_1)); Assert.That(parent.Children.Contains(child_2)); Assert.That(child_1.Parent, Is.EqualTo(parent)); Assert.That(child_1.Sequence, Is.EqualTo(3)); }
public void ChangeParent() { Task parent_1 = new Task(); Task parent_2 = new Task(); Task child = new Task(); parent_1.AddChild(child); Assert.That(child.Parent, Is.EqualTo(parent_1)); Assert.That(parent_1.Children.Count, Is.EqualTo(1)); Assert.That(parent_1.Children.Contains(child)); child.ChangeParent(parent_2); Assert.That(child.Parent, Is.EqualTo(parent_2)); Assert.That(parent_1.Children.IsNullOrEmpty(), Is.True); Assert.That(parent_2.Children.Count, Is.EqualTo(1)); Assert.That(parent_2.Children.Contains(child)); }
private Task get_task_with_parents() { Task task = new Task(); task.AddChild(new Task()); task.Children[0].AddChild(new Task()); return task.Children[0].Children[0]; }
private Task get_task_with_brothers_and_parents() { Task root = new Task { Accepter = new User() }; root.BeginWork(); Task branch_1 = new Task { Accepter = new User() }; branch_1.BeginWork(); root.AddChild(branch_1); Task branch_2 = new Task { Accepter = new User() }; branch_2.CurrentStatus = Status.Complete; root.AddChild(branch_2); Task leaf_1 = new Task { Accepter = new User() }; leaf_1.BeginWork(); branch_1.AddChild(leaf_1); Task leaf_2 = new Task { Accepter = new User() }; leaf_2.CurrentStatus = Status.Complete; branch_1.AddChild(leaf_2); return leaf_1; }
public void Accept_With_Parent() { #region preparation Task task = new Task { Project = get_project() }; Task brother = new Task { Project = get_project() }; Task parent = new Task { IsVirtual = true, Project = get_project() }; parent.AddChild(task); parent.AddChild(brother); TaskQuality Quality = TaskQuality.Good; #endregion #region only the brother is accept, not affect parent brother.Accept(Quality); brother.has_accept(Quality); Assert.That(parent.CurrentStatus, Is.Not.EqualTo(Status.Accept)); #endregion #region both the brother and task are accepted, affect their parent now task.Accept(Quality); task.AutoAcceptAncestors(); task.has_accept(Quality); parent.has_accept(Constants.CommentAutoAcceptForChildren); Assert.That(parent.Quality, Is.Null); #endregion }
public void ChangeParent_When_New_Parent_Is_Old_Parent() { Task parent = new Task(); Task child_1 = new Task(); Task child_2 = new Task(); parent.AddChild(child_1); parent.AddChild(child_2); child_1.ChangeParent(parent); Assert.That(child_1.Parent, Is.EqualTo(parent)); Assert.That(child_1.Sequence, Is.EqualTo(1)); Assert.That(child_2.Parent, Is.EqualTo(parent)); Assert.That(child_2.Sequence, Is.EqualTo(2)); Assert.That(parent.Children.Count, Is.EqualTo(2)); Assert.That(parent.Children.Contains(child_1)); Assert.That(parent.Children.Contains(child_1)); }
public void IsOffspring() { Task child_1 = new Task(); Task child_2 = new Task(); Task parent_1 = new Task(); Task parent_2 = new Task(); Task grand_parent = new Task(); Task other = new Task(); parent_1.AddChild(child_1); parent_1.AddChild(child_2); grand_parent.AddChild(parent_1); grand_parent.AddChild(parent_2); Assert.That(child_1.IsOffspring(parent_1), Is.True); Assert.That(child_2.IsOffspring(parent_1), Is.True); Assert.That(parent_1.IsOffspring(parent_1), Is.False); Assert.That(parent_2.IsOffspring(parent_1), Is.False); Assert.That(grand_parent.IsOffspring(parent_1), Is.False); Assert.That(other.IsOffspring(parent_1), Is.False); Assert.That(child_1.IsOffspring(parent_2), Is.False); Assert.That(child_2.IsOffspring(parent_2), Is.False); Assert.That(parent_1.IsOffspring(parent_2), Is.False); Assert.That(parent_2.IsOffspring(parent_2), Is.False); Assert.That(grand_parent.IsOffspring(parent_1), Is.False); Assert.That(other.IsOffspring(parent_1), Is.False); Assert.That(child_1.IsOffspring(grand_parent), Is.True); Assert.That(child_2.IsOffspring(grand_parent), Is.True); Assert.That(parent_1.IsOffspring(grand_parent), Is.True); Assert.That(parent_2.IsOffspring(grand_parent), Is.True); Assert.That(grand_parent.IsOffspring(grand_parent), Is.False); Assert.That(other.IsOffspring(grand_parent), Is.False); }
public void RemoveParent() { Task parent = new Task(); Task child = new Task(); //child no parent child.RemoveParent(); Assert.That(child.Parent, Is.Null); parent.AddChild(child); //child have parent child.RemoveParent(); Assert.That(child.Parent, Is.Null); Assert.That(parent.Children.IsNullOrEmpty(), Is.True); }
public void IsLastInBrothers() { Task parent = new Task(); parent.SetPropertyInBase("Id", 1); Task first_task = new Task { CurrentStatus = Status.Assign }; first_task.SetPropertyInBase("Id", 2); Task middle_task = new Task { CurrentStatus = Status.Assign }; middle_task.SetPropertyInBase("Id", 3); Task last_task = new Task { CurrentStatus = Status.Accept }; last_task.SetPropertyInBase("Id", 4); parent.AddChild(first_task); parent.AddChild(middle_task); parent.AddChild(last_task); Assert.That(first_task.IsLastInBrothers(Status.Assign), Is.False); Assert.That(middle_task.IsLastInBrothers(Status.Assign), Is.False); //all other brothers are Assign status except himselft, so he's the last one with Assign status. Assert.That(last_task.IsLastInBrothers(Status.Assign), Is.True); }
public void GetNext() { Task parent = new Task(); Task first_task = new Task(); Task middle_task = new Task(); Task last_task = new Task(); parent.AddChild(first_task); parent.AddChild(middle_task); parent.AddChild(last_task); Assert.That(parent.GetNext(), Is.Null); Assert.That(first_task.GetNext(), Is.EqualTo(middle_task)); Assert.That(middle_task.GetNext(), Is.EqualTo(last_task)); Assert.That(last_task.GetNext(), Is.Null); }
public virtual void ChangeParent(Task newParent) { if (Parent == null) { newParent.AddChild(this); } else if (Parent != newParent) { Parent.RemoveChild(this); newParent.AddChild(this); } }