本文整理汇总了C#中ProjectManager.TasksOf方法的典型用法代码示例。如果您正苦于以下问题:C# ProjectManager.TasksOf方法的具体用法?C# ProjectManager.TasksOf怎么用?C# ProjectManager.TasksOf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProjectManager
的用法示例。
在下文中一共展示了ProjectManager.TasksOf方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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");
}
示例2: UnassignResourceFromAllTask
public void UnassignResourceFromAllTask()
{
IProjectManager<Task, object> manager = new ProjectManager<Task, object>();
var one = new Task();
var two = new Task();
var r1 = new object();
var r2 = new object();
manager.Add(one);
manager.Add(two);
// setup: assign some resource
manager.Assign(one, r1);
manager.Assign(one, r2);
manager.Assign(two, r1);
manager.Assign(two, r2);
Assert.IsTrue(manager.Resources.Count() == 2);
Assert.IsTrue(manager.ResourcesOf(one).Contains(r1));
Assert.IsTrue(manager.ResourcesOf(one).Contains(r2));
Assert.IsTrue(manager.ResourcesOf(two).Contains(r1));
Assert.IsTrue(manager.ResourcesOf(two).Contains(r2));
Assert.IsTrue(manager.TasksOf(r1).Contains(one));
Assert.IsTrue(manager.TasksOf(r2).Contains(one));
Assert.IsTrue(manager.TasksOf(r1).Contains(two));
Assert.IsTrue(manager.TasksOf(r2).Contains(two));
manager.Unassign(r1);
Assert.IsTrue(manager.Resources.Count() == 1, string.Format("Expected {0} != {1}", 1, manager.Resources.Count()));
Assert.IsTrue(!manager.ResourcesOf(one).Contains(r1));
Assert.IsTrue(manager.ResourcesOf(one).Contains(r2));
Assert.IsTrue(!manager.ResourcesOf(two).Contains(r1));
Assert.IsTrue(manager.ResourcesOf(two).Contains(r2));
Assert.IsTrue(!manager.TasksOf(r1).Contains(one));
Assert.IsTrue(manager.TasksOf(r2).Contains(one));
Assert.IsTrue(!manager.TasksOf(r1).Contains(two));
Assert.IsTrue(manager.TasksOf(r2).Contains(two));
}
示例3: UnassignSpecificResource
public void UnassignSpecificResource()
{
IProjectManager<Task, object> manager = new ProjectManager<Task, object>();
var one = new Task();
var r1 = new Task();
var r2 = new Task();
manager.Add(one);
// setup: assign some resource
manager.Assign(one, r1);
manager.Assign(one, r2);
Assert.IsTrue(manager.Resources.Count() == 2);
Assert.IsTrue(manager.ResourcesOf(one).Contains(r1));
Assert.IsTrue(manager.ResourcesOf(one).Contains(r2));
Assert.IsTrue(manager.TasksOf(r1).Contains(one));
Assert.IsTrue(manager.TasksOf(r2).Contains(one));
// test: unassign resource
manager.Unassign(one, r2);
Assert.IsTrue(manager.Resources.Count() == 1);
Assert.IsTrue(manager.ResourcesOf(one).Contains(r1));
Assert.IsTrue(!manager.ResourcesOf(one).Contains(r2));
Assert.IsTrue(manager.TasksOf(r1).Contains(one));
Assert.IsTrue(!manager.TasksOf(r2).Contains(one));
}
示例4: TwoWayResourceLookup
public void TwoWayResourceLookup()
{
IProjectManager<Task, object> manager = new ProjectManager<Task, object>();
var one = new Task();
var two = new Task();
var r1 = new Task();
var r2 = new Task();
manager.Add(one);
manager.Add(two);
// check initializations are correct
Assert.IsTrue(manager.ResourcesOf(one) != null);
Assert.IsTrue(manager.ResourcesOf(one).Count() == 0);
Assert.IsTrue(manager.ResourcesOf(two) != null);
Assert.IsTrue(manager.ResourcesOf(two).Count() == 0);
// assign resource
manager.Assign(one, r1);
Assert.IsTrue(manager.ResourcesOf(one) != null);
Assert.IsTrue(manager.ResourcesOf(one).Count() == 1);
Assert.IsTrue(manager.ResourcesOf(one).FirstOrDefault().Equals(r1));
Assert.IsTrue(manager.TasksOf(r1).Count() == 1);
Assert.IsTrue(manager.TasksOf(r1).FirstOrDefault().Equals(one));
// assign another resource
manager.Assign(one, r2);
Assert.IsTrue(manager.ResourcesOf(one) != null);
Assert.IsTrue(manager.ResourcesOf(one).Count() == 2);
Assert.IsTrue(manager.ResourcesOf(one).ElementAtOrDefault(1).Equals(r2));
Assert.IsTrue(manager.TasksOf(r2).Count() == 1);
Assert.IsTrue(manager.TasksOf(r2).FirstOrDefault().Equals(one));
// assign resource to another task
manager.Assign(two, r2);
Assert.IsTrue(manager.ResourcesOf(two) != null);
Assert.IsTrue(manager.ResourcesOf(two).Count() == 1);
Assert.IsTrue(manager.ResourcesOf(two).FirstOrDefault().Equals(r2));
Assert.IsTrue(manager.TasksOf(r2).Count() == 2);
Assert.IsTrue(manager.TasksOf(r2).ElementAtOrDefault(1).Equals(two));
}
示例5: UnassignAllResourceFromTask
public void UnassignAllResourceFromTask()
{
IProjectManager<Task, object> manager = new ProjectManager<Task, object>();
var one = new Task();
var two = new Task();
var r1 = new Task();
var r2 = new Task();
manager.Add(one);
manager.Add(two);
// setup: assign some resource
manager.Assign(one, r1);
manager.Assign(one, r2);
manager.Assign(two, r1);
manager.Assign(two, r2);
Assert.IsTrue(manager.Resources.Count() == 2);
Assert.IsTrue(manager.ResourcesOf(one).Contains(r1));
Assert.IsTrue(manager.ResourcesOf(one).Contains(r2));
Assert.IsTrue(manager.ResourcesOf(two).Contains(r1));
Assert.IsTrue(manager.ResourcesOf(two).Contains(r2));
Assert.IsTrue(manager.TasksOf(r1).Contains(one));
Assert.IsTrue(manager.TasksOf(r2).Contains(one));
Assert.IsTrue(manager.TasksOf(r1).Contains(two));
Assert.IsTrue(manager.TasksOf(r2).Contains(two));
manager.Unassign(one);
Assert.IsTrue(manager.Resources.Count() == 2);
Assert.IsTrue(!manager.ResourcesOf(one).Contains(r1));
Assert.IsTrue(!manager.ResourcesOf(one).Contains(r2));
Assert.IsTrue(manager.ResourcesOf(two).Contains(r1));
Assert.IsTrue(manager.ResourcesOf(two).Contains(r2));
Assert.IsTrue(!manager.TasksOf(r1).Contains(one));
Assert.IsTrue(!manager.TasksOf(r2).Contains(one));
Assert.IsTrue(manager.TasksOf(r1).Contains(two));
Assert.IsTrue(manager.TasksOf(r2).Contains(two));
}
示例6: AssignSameResourceToDifferentTask
public void AssignSameResourceToDifferentTask()
{
IProjectManager<Task, object> manager = new ProjectManager<Task, object>();
var one = new Task();
var two = new Task();
var res = new Task() { Name = "Resource" };
manager.Add(one);
manager.Add(two);
// setup: assign resource
manager.Assign(one, res);
Assert.IsTrue(manager.Resources.Count() == 1);
Assert.IsTrue(manager.ResourcesOf(one).Count() == 1);
Assert.IsTrue(manager.TasksOf(res).Count() == 1);
Assert.IsTrue(manager.Resources.Contains(res));
Assert.IsTrue(manager.ResourcesOf(one).Contains(res));
Assert.IsTrue(manager.TasksOf(res).Contains(one));
// setup: assign resource. no extra resource should be created. resource reference shared by 2 tasks
manager.Assign(two, res);
Assert.IsTrue(manager.Resources.Count() == 1);
Assert.IsTrue(manager.ResourcesOf(one).Count() == 1);
Assert.IsTrue(manager.ResourcesOf(two).Count() == 1);
Assert.IsTrue(manager.TasksOf(res).Count() == 2);
Assert.IsTrue(manager.Resources.Contains(res));
Assert.IsTrue(manager.ResourcesOf(one).Contains(res));
Assert.IsTrue(manager.ResourcesOf(two).Contains(res));
Assert.IsTrue(manager.TasksOf(res).Contains(one));
Assert.IsTrue(manager.TasksOf(res).Contains(two));
}
示例7: AssignSameResourceToSameTask
public void AssignSameResourceToSameTask()
{
IProjectManager<Task, object> manager = new ProjectManager<Task, object>();
var one = new Task();
var res = new Task() { Name = "Resource" };
manager.Add(one);
// setup: assign resource
manager.Assign(one, res);
Assert.IsTrue(manager.Resources.Count() == 1);
Assert.IsTrue(manager.ResourcesOf(one).Count() == 1);
Assert.IsTrue(manager.TasksOf(res).Count() == 1);
Assert.IsTrue(manager.Resources.Contains(res));
Assert.IsTrue(manager.ResourcesOf(one).Contains(res));
Assert.IsTrue(manager.TasksOf(res).Contains(one));
// test: assign the same resource to the same task (no effect, as resource is already assigned)
manager.Assign(one, res);
Assert.IsTrue(manager.Resources.Count() == 1);
Assert.IsTrue(manager.ResourcesOf(one).Count() == 1);
Assert.IsTrue(manager.TasksOf(res).Count() == 1);
Assert.IsTrue(manager.Resources.Contains(res));
Assert.IsTrue(manager.ResourcesOf(one).Contains(res));
Assert.IsTrue(manager.TasksOf(res).Contains(one));
}
示例8: AssignResourceForUnknownTasks
public void AssignResourceForUnknownTasks()
{
IProjectManager<Task, object> manager = new ProjectManager<Task, object>();
var one = new Task();
var res = new Task() { Name = "Resource" };
// setup: confirm there is no resource
Assert.IsTrue(manager.Resources.Count() == 0);
Assert.IsTrue(manager.ResourcesOf(one).Count() == 0);
Assert.IsTrue(manager.TasksOf(res).Count() == 0);
// test: assign resource
manager.Assign(one, res);
Assert.IsTrue(manager.Resources.Count() == 0);
Assert.IsTrue(manager.ResourcesOf(one).Count() == 0);
Assert.IsTrue(manager.TasksOf(res).Count() == 0);
}
示例9: 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));
}
示例10: DeleteResourcesOnDeleteSplitTask
public void DeleteResourcesOnDeleteSplitTask()
{
IProjectManager<Task, object> manager = new ProjectManager<Task, object>();
var split = new Task();
var part1 = new Task();
var part2 = new Task();
var r1 = new Task();
manager.Add(split);
// setup: create a split task with resources on parts
manager.Split(split, part1, part2, 1);
manager.Assign(part1, r1);
manager.Assign(part2, r1);
Assert.IsTrue(!manager.TasksOf(r1).Contains(split));
Assert.IsTrue(manager.TasksOf(r1).Contains(part1));
Assert.IsTrue(manager.TasksOf(r1).Contains(part2));
Assert.IsTrue(!manager.ResourcesOf(split).Contains(r1));
Assert.IsTrue(manager.ResourcesOf(part1).Contains(r1));
Assert.IsTrue(manager.ResourcesOf(part2).Contains(r1));
Assert.IsTrue(manager.Resources.Count() == 1);
Assert.IsTrue(manager.Tasks.Count() == 1);
// test: delete the split task, everything should go
manager.Delete(split);
Assert.IsTrue(manager.Resources.Count() == 0);
Assert.IsTrue(manager.Tasks.Count() == 0);
Assert.IsTrue(!manager.TasksOf(r1).Contains(split));
Assert.IsTrue(!manager.TasksOf(r1).Contains(part1));
Assert.IsTrue(!manager.TasksOf(r1).Contains(part2));
Assert.IsTrue(!manager.ResourcesOf(split).Contains(r1));
Assert.IsTrue(!manager.ResourcesOf(part1).Contains(r1));
Assert.IsTrue(!manager.ResourcesOf(part2).Contains(r1));
// test: check that they are really deleted by adding them back again
manager.Add(split);
manager.Add(part1);
manager.Add(part2);
Assert.IsTrue(manager.Tasks.Count() == 3);
}
示例11: DeleteResourceOnDeleteTask
public void DeleteResourceOnDeleteTask()
{
IProjectManager<Task, object> manager = new ProjectManager<Task, object>();
var task1 = new Task();
var task2 = new Task();
var r1 = new Task();
manager.Add(task1);
manager.Add(task2);
// setup: assign resource
manager.Assign(task1, r1);
manager.Assign(task2, r1);
Assert.IsTrue(manager.ResourcesOf(task1).Contains(r1));
Assert.IsTrue(manager.ResourcesOf(task2).Contains(r1));
Assert.IsTrue(manager.TasksOf(r1).Count() == 2);
// test: delete task1
manager.Delete(task1);
Assert.IsTrue(!manager.ResourcesOf(task1).Contains(r1));
Assert.IsTrue(manager.ResourcesOf(task2).Contains(r1));
Assert.IsTrue(manager.TasksOf(r1).Count() == 1);
Assert.IsTrue(manager.Resources.Count() == 1);
Assert.IsTrue(manager.Resources.Contains(r1));
// test: delete task2
manager.Delete(task2);
Assert.IsTrue(!manager.ResourcesOf(task1).Contains(r1));
Assert.IsTrue(!manager.ResourcesOf(task2).Contains(r1));
Assert.IsTrue(manager.TasksOf(r1).Count() == 0);
Assert.IsTrue(manager.Resources.Count() == 0);
Assert.IsTrue(!manager.Resources.Contains(r1));
}
示例12: TransferResourceToSplitTaskOnMerge_ByDeleteInThisCase
public void TransferResourceToSplitTaskOnMerge_ByDeleteInThisCase()
{
IProjectManager<Task, object> manager = new ProjectManager<Task, object>();
var split = new Task();
var part1 = new Task();
var part2 = new Task();
var r1 = new Task();
manager.Add(split);
// setup: create a split task with resources on parts
manager.Split(split, part1, part2, 1);
manager.Assign(part1, r1);
manager.Assign(part2, r1);
Assert.IsTrue(!manager.TasksOf(r1).Contains(split));
Assert.IsTrue(manager.TasksOf(r1).Contains(part1));
Assert.IsTrue(manager.TasksOf(r1).Contains(part2));
Assert.IsTrue(!manager.ResourcesOf(split).Contains(r1));
Assert.IsTrue(manager.ResourcesOf(part1).Contains(r1));
Assert.IsTrue(manager.ResourcesOf(part2).Contains(r1));
Assert.IsTrue(manager.Resources.Count() == 1);
// test: delete a part, expect a merge and resources transferred to split task
manager.Delete(part1);
Assert.IsTrue(manager.TasksOf(r1).Contains(split));
Assert.IsTrue(!manager.TasksOf(r1).Contains(part1));
Assert.IsTrue(!manager.TasksOf(r1).Contains(part2));
Assert.IsTrue(manager.ResourcesOf(split).Contains(r1));
Assert.IsTrue(!manager.ResourcesOf(part1).Contains(r1));
Assert.IsTrue(!manager.ResourcesOf(part2).Contains(r1));
Assert.IsTrue(manager.Resources.Count() == 1);
}