本文整理汇总了C#中ProjectManager.PrecedentsOf方法的典型用法代码示例。如果您正苦于以下问题:C# ProjectManager.PrecedentsOf方法的具体用法?C# ProjectManager.PrecedentsOf怎么用?C# ProjectManager.PrecedentsOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProjectManager
的用法示例。
在下文中一共展示了ProjectManager.PrecedentsOf方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AllowRelateSplitTaskToTask
public void AllowRelateSplitTaskToTask()
{
IProjectManager<Task, object> manager = new ProjectManager<Task, object>();
var split = new Task();
var part1a = new Task();
var part1b = new Task();
var task = new Task();
manager.Add(split);
manager.Add(task);
// setup: create a split task
manager.Split(split, part1a, part1b, 1);
Assert.IsTrue(manager.IsSplit(split));
Assert.IsTrue(!manager.IsSplit(part1a));
Assert.IsTrue(!manager.IsSplit(part1b));
Assert.IsTrue(!manager.IsPart(split));
Assert.IsTrue(manager.IsPart(part1a));
Assert.IsTrue(manager.IsPart(part1b));
Assert.IsTrue(!manager.HasRelations(split));
Assert.IsTrue(!manager.HasRelations(part1a));
Assert.IsTrue(!manager.HasRelations(part1b));
Assert.IsTrue(!manager.HasRelations(task));
// test: relate task and split task
manager.Relate(task, split);
Assert.IsTrue(manager.IsSplit(split));
Assert.IsTrue(!manager.IsSplit(part1a));
Assert.IsTrue(!manager.IsSplit(part1b));
Assert.IsTrue(!manager.IsPart(split));
Assert.IsTrue(manager.IsPart(part1a));
Assert.IsTrue(manager.IsPart(part1b));
Assert.IsTrue(manager.HasRelations(split));
Assert.IsTrue(!manager.HasRelations(part1a));
Assert.IsTrue(!manager.HasRelations(part1b));
Assert.IsTrue(manager.HasRelations(task));
Assert.IsTrue(manager.PrecedentsOf(split).Contains(task));
}
示例2: CreateRelationThatAlreadyExist
public void CreateRelationThatAlreadyExist()
{
IProjectManager<Task, object> manager = new ProjectManager<Task, object>();
var one = new Task();
var two = new Task();
manager.Add(one);
manager.Add(two);
// setup: create a relationship
manager.Relate(one, two);
Assert.IsTrue(manager.DependantsOf(one).Contains(two));
Assert.IsTrue(manager.PrecedentsOf(two).Contains(one));
// test: re-create the relationship (no effect)
manager.Relate(one, two);
Assert.IsTrue(manager.DependantsOf(one).Contains(two));
Assert.IsTrue(manager.PrecedentsOf(two).Contains(one));
}
示例3: EnumerationShouldReturnEmptySet
public void EnumerationShouldReturnEmptySet()
{
IProjectManager<Task, object> manager = new ProjectManager<Task, object>();
var alien = new Task();
// test: Enumerators should at least return empty sets
Assert.IsNotNull(manager.ChildrenOf(alien), "ChildrenOf is null");
Assert.IsNotNull(manager.AncestorsOf(alien), "AncestorsOf is null");
Assert.IsNotNull(manager.DecendantsOf(alien), "DecendantsOf is null");
Assert.IsNotNull(manager.DependantsOf(alien), "DependantsOf is null");
Assert.IsNotNull(manager.PrecedentsOf(alien), "PrecedentsOf is null");
Assert.IsNotNull(manager.DirectDependantsOf(alien), "DirectDependantsOf is null");
Assert.IsNotNull(manager.DirectPrecedentsOf(alien), "DirectPrecedentsOf is null");
Assert.IsNotNull(manager.ResourcesOf(alien), "ResourcesOf is null");
Assert.IsNotNull(manager.TasksOf(alien), "TasksOf is null");
}
示例4: Create3LevelRelations
public void Create3LevelRelations()
{
IProjectManager<Task, object> manager = new ProjectManager<Task, object>();
var one = new Task();
var two = new Task();
var three = new Task();
manager.Add(one);
manager.Add(two);
manager.Add(three);
// setup: one before two before three
manager.Relate(one, two);
manager.Relate(two, three);
// test: check enumerations are established
Assert.IsTrue(manager.DependantsOf(one).Count() == 2);
Assert.IsTrue(manager.DependantsOf(two).Count() == 1);
Assert.IsTrue(manager.DependantsOf(three).Count() == 0);
Assert.IsTrue(manager.DirectDependantsOf(one).Count() == 1);
Assert.IsTrue(manager.DirectDependantsOf(two).Count() == 1);
Assert.IsTrue(manager.DirectDependantsOf(three).Count() == 0);
Assert.IsTrue(manager.PrecedentsOf(one).Count() == 0);
Assert.IsTrue(manager.PrecedentsOf(two).Count() == 1, string.Format("expected {0} != {1}", 1, manager.PrecedentsOf(two).Count()));
Assert.IsTrue(manager.PrecedentsOf(three).Count() == 2);
Assert.IsTrue(manager.DirectPrecedentsOf(one).Count() == 0);
Assert.IsTrue(manager.DirectPrecedentsOf(two).Count() == 1);
Assert.IsTrue(manager.DirectPrecedentsOf(three).Count() == 1);
}
示例5: CreateRelation
public void CreateRelation()
{
IProjectManager<Task, object> manager = new ProjectManager<Task, object>();
var one = new Task();
var two = new Task();
manager.Add(one);
manager.Add(two);
// setup: confirms no relations
Assert.IsTrue(manager.DependantsOf(one).Count() == 0);
Assert.IsTrue(manager.PrecedentsOf(two).Count() == 0);
// test: create a relationship
manager.Relate(one, two);
Assert.IsTrue(manager.DependantsOf(one).Contains(two));
Assert.IsTrue(manager.PrecedentsOf(two).Contains(one));
Assert.IsTrue(manager.HasRelations(one));
Assert.IsTrue(manager.HasRelations(two));
}
示例6: CircularRelationLevel1
public void CircularRelationLevel1()
{
IProjectManager<Task, object> manager = new ProjectManager<Task, object>();
var one = new Task();
var two = new Task();
manager.Add(one);
manager.Add(two);
// setup: create a relationship
manager.Relate(one, two);
Assert.IsTrue(manager.DependantsOf(one).Contains(two));
Assert.IsTrue(manager.DependantsOf(one).Count() == 1);
Assert.IsTrue(manager.PrecedentsOf(one).Count() == 0);
Assert.IsTrue(manager.PrecedentsOf(two).Contains(one));
Assert.IsTrue(manager.PrecedentsOf(two).Count() == 1);
Assert.IsTrue(manager.DependantsOf(two).Count() == 0);
// test: cycle the relationship (no effect)
manager.Relate(two, one);
Assert.IsTrue(manager.DependantsOf(one).Contains(two));
Assert.IsTrue(manager.DependantsOf(one).Count() == 1);
Assert.IsTrue(manager.PrecedentsOf(one).Count() == 0);
Assert.IsTrue(manager.PrecedentsOf(two).Contains(one));
Assert.IsTrue(manager.PrecedentsOf(two).Count() == 1);
Assert.IsTrue(manager.DependantsOf(two).Count() == 0);
}
示例7: CircularRelationLevel2
public void CircularRelationLevel2()
{
IProjectManager<Task, object> manager = new ProjectManager<Task, object>();
var one = new Task();
var two = new Task();
var three = new Task();
manager.Add(one);
manager.Add(two);
manager.Add(three);
// setup: one before two before three;
manager.Relate(one, two);
manager.Relate(two, three);
Assert.IsTrue(manager.HasRelations(one));
Assert.IsTrue(manager.HasRelations(two));
Assert.IsTrue(manager.HasRelations(three));
Assert.IsTrue(manager.DirectDependantsOf(one).Contains(two));
Assert.IsTrue(manager.DirectDependantsOf(two).Contains(three));
Assert.IsTrue(manager.PrecedentsOf(three).Contains(one));
Assert.IsTrue(manager.PrecedentsOf(three).Contains(two));
// test: prevent circular relation (no effect)
manager.Relate(three, one);
Assert.IsTrue(manager.HasRelations(one));
Assert.IsTrue(manager.HasRelations(two));
Assert.IsTrue(manager.HasRelations(three));
Assert.IsTrue(manager.DirectDependantsOf(one).Contains(two));
Assert.IsTrue(manager.DirectDependantsOf(two).Contains(three));
Assert.IsTrue(manager.PrecedentsOf(three).Contains(one));
Assert.IsTrue(manager.PrecedentsOf(three).Contains(two));
}
示例8: RemoveExistingRelation
public void RemoveExistingRelation()
{
IProjectManager<Task, object> manager = new ProjectManager<Task, object>();
var one = new Task();
var two = new Task();
manager.Add(one);
manager.Add(two);
// setup: create a relationship
manager.Relate(one, two);
Assert.IsTrue(manager.DependantsOf(one).Contains(two));
Assert.IsTrue(manager.PrecedentsOf(two).Contains(one));
// test: remove relation
manager.Unrelate(one, two);
Assert.IsTrue(manager.DependantsOf(one).Count() == 0);
Assert.IsTrue(manager.PrecedentsOf(two).Count() == 0);
}
示例9: RemoveAllDependantsRelation
public void RemoveAllDependantsRelation()
{
IProjectManager<Task, object> manager = new ProjectManager<Task, object>();
var one = new Task();
var two = new Task();
var three = new Task();
var four = new Task();
manager.Add(one);
manager.Add(two);
manager.Add(three);
manager.Add(four);
// setup: create a relationship
manager.Relate(four, one);
manager.Relate(one, two);
manager.Relate(one, three);
Assert.IsTrue(manager.DependantsOf(one).Contains(three));
Assert.IsTrue(manager.PrecedentsOf(two).Contains(one));
Assert.IsTrue(manager.PrecedentsOf(three).Contains(one));
Assert.IsTrue(manager.DependantsOf(four).Contains(one));
Assert.IsTrue(manager.PrecedentsOf(one).Contains(four));
// test: remove dependants
manager.Unrelate(one);
Assert.IsTrue(manager.DependantsOf(one).Count() == 0);
Assert.IsTrue(manager.PrecedentsOf(two).Count() == 0);
Assert.IsTrue(manager.PrecedentsOf(three).Count() == 0);
Assert.IsTrue(manager.DependantsOf(four).Contains(one));
Assert.IsTrue(manager.PrecedentsOf(one).Contains(four));
}
示例10: KnownTasksEnumeration
public void KnownTasksEnumeration()
{
IProjectManager<Task, object> manager = new ProjectManager<Task, object>();
var local = new Task();
manager.Add(local);
Assert.IsNotNull(manager.ChildrenOf(local));
Assert.IsNotNull(manager.AncestorsOf(local));
Assert.IsNotNull(manager.DecendantsOf(local));
Assert.IsNotNull(manager.DependantsOf(local));
Assert.IsNotNull(manager.PrecedentsOf(local));
Assert.IsNotNull(manager.DirectDependantsOf(local));
Assert.IsNotNull(manager.DirectPrecedentsOf(local));
Assert.IsNotNull(manager.ResourcesOf(local));
Assert.IsNotNull(manager.TasksOf(local));
}
示例11: CriticalPath
public void CriticalPath()
{
IProjectManager<Task, object> manager = new ProjectManager<Task, object>();
var one = new Task();
var two = new Task();
var three = new Task();
var four = new Task();
var five = new Task();
var six = new Task();
var seven = new Task();
var eight = new Task();
var nine = new Task();
var group1 = new Task() { Name = "group1" };
var group2 = new Task() { Name = "group2" };
manager.Add(one);
manager.Add(two);
manager.Add(three);
manager.Add(four);
manager.Add(five);
manager.Add(six);
manager.Add(seven);
manager.Add(eight);
manager.Add(nine);
manager.Add(group1);
manager.Add(group2);
// setup: create some schedules and grouping, and confirm we laid it out correctly
manager.Relate(one, two);
manager.Relate(one, three);
manager.Relate(three, four);
manager.Relate(five, six);
manager.Relate(six, four);
manager.Relate(six, seven);
manager.Relate(six, eight);
manager.Relate(eight, nine);
manager.Group(group1, one);
manager.Group(group1, two);
manager.Group(group1, three);
manager.Group(group1, four);
manager.Group(group2, five);
manager.Group(group2, six);
manager.Group(group2, seven);
manager.Group(group2, eight);
manager.SetStart(one, 0); manager.SetEnd(one, 3);
manager.SetStart(two, 4); manager.SetEnd(two, 7);
manager.SetStart(three, 5); manager.SetEnd(three, 8);
manager.SetStart(four, 10); manager.SetEnd(four, 15);
manager.SetStart(five, 1); manager.SetEnd(five, 5);
manager.SetStart(six, 6); manager.SetEnd(six, 9);
manager.SetStart(seven, 12); manager.SetEnd(seven, 15);
manager.SetStart(eight, 11); manager.SetEnd(eight, 16);
manager.SetStart(nine, 17); manager.SetEnd(nine, 20);
Assert.IsTrue(one.Start == 0 && one.Duration == 3, string.Format("Expected ({0}, {1}) != ({2}, {3})", 0, 3, one.Start, one.Duration));
Assert.IsTrue(two.Start == 4 && two.Duration == 3);
Assert.IsTrue(three.Start == 5 && three.Duration == 3);
Assert.IsTrue(four.Start == 10 && four.Duration == 5);
Assert.IsTrue(five.Start == 1 && five.Duration == 4);
Assert.IsTrue(six.Start == 6 && six.Duration == 3);
Assert.IsTrue(seven.Start == 12 && seven.Duration == 3);
Assert.IsTrue(eight.Start == 11 && eight.Duration == 5);
Assert.IsTrue(nine.Start == 17 && nine.Duration == 3, string.Format("Expected ({0}, {1}) != ({2}, {3})", 17, 3, nine.Start, nine.Duration));
var iter_nine = manager.PrecedentsOf(nine).GetEnumerator(); // nine is critical in this setup
iter_nine.MoveNext(); Assert.IsTrue(iter_nine.Current.Equals(eight));
iter_nine.MoveNext(); Assert.IsTrue(iter_nine.Current.Equals(six));
iter_nine.MoveNext(); Assert.IsTrue(iter_nine.Current.Equals(five));
Assert.IsTrue(iter_nine.MoveNext() == false);
// test: change the critical path and see if it gets updated correctly
manager.SetStart(four, 17); // four now ends later than 9;
var critical_paths = manager.CriticalPaths; // should have 2 paths: 4 to 1; and 4 to 5;
Assert.IsTrue(critical_paths.Count() == 2, string.Format("Expected {0} != {1}", 2, critical_paths.Count()));
var critical_tasks = critical_paths.SelectMany(x => x);
Assert.IsTrue(critical_tasks.Distinct().Count() == 6, string.Format("Expected {0} != {1}", 5, critical_tasks.Distinct().Count())); // 4, 3, 1, 6, 5, group1
Assert.IsTrue(critical_tasks.Contains(four));
Assert.IsTrue(critical_tasks.Contains(three));
Assert.IsTrue(critical_tasks.Contains(one));
Assert.IsTrue(critical_tasks.Contains(six));
Assert.IsTrue(critical_tasks.Contains(five));
Assert.IsTrue(critical_tasks.Contains(group1));
}
示例12: CannotStartPartBeforeSplitTaskPrecedentStart
public void CannotStartPartBeforeSplitTaskPrecedentStart()
{
IProjectManager<Task, object> manager = new ProjectManager<Task, object>();
var split = new Task();
var part1 = new Task();
var part2 = new Task();
var precedent = new Task();
manager.Add(split);
manager.Add(precedent);
// setup: create a split task with precendent
manager.SetStart(precedent, 5);
manager.SetDuration(precedent, 5);
manager.SetStart(split, 15);
manager.SetDuration(split, 5);
manager.Relate(precedent, split);
manager.Split(split, part1, part2, 2);
Assert.IsTrue(manager.PrecedentsOf(split).Contains(precedent));
Assert.IsTrue(manager.PartsOf(split).Contains(part1));
Assert.IsTrue(manager.PartsOf(split).Contains(part2));
Assert.IsTrue(precedent.End == 10);
Assert.IsTrue(split.Start == 15);
Assert.IsTrue(part1.Start == 15);
// test: move part1 start before precendent start
manager.SetStart(part1, 8);
Assert.IsTrue(manager.PrecedentsOf(split).Contains(precedent));
Assert.IsTrue(manager.PartsOf(split).Contains(part1));
Assert.IsTrue(manager.PartsOf(split).Contains(part2));
Assert.IsTrue(part1.Start == 11);
Assert.IsTrue(split.Start == 11);
}