Exemplo n.º 1
0
        public TaskRelationModel GetRelation(int taskId)
        {
            TaskRelationModel model = new TaskRelationModel();
            Task task = session.Load<Task>(taskId);
            model.FilledBy(task);

            return model;
        }
Exemplo n.º 2
0
        public TaskRelationModel GetRelation(int taskId)
        {
            TaskRelationModel model = new TaskRelationModel();
            model.Current = new LiteItemModel
            {
                Id = 1,
                Title = "当前任务"
            };

            model.Ancestor = new LinkedList<LiteItemModel>();
            LiteItemModel root = new LiteItemModel
            {
                Id = 2,
                Title = "这是根任务 "
            };
            LiteItemModel parent = new LiteItemModel
            {
                Id = 3,
                Title = "这个是父任务 "
            };
            model.Ancestor.AddFirst(parent);
            model.Ancestor.AddFirst(root);

            model.Brothers = new List<LiteItemModel>();
            LiteItemModel brother_1 = new LiteItemModel
            {
                Id = 4,
                Title = "这个是兄弟任务1"
            };
            LiteItemModel brother_2 = new LiteItemModel
            {
                Id = 5,
                Title = "这个是兄弟任务2 "
            };
            model.Brothers.Add(brother_1);
            model.Brothers.Add(brother_2);


            model.Children = new List<LiteItemModel>();
            LiteItemModel child_1 = new LiteItemModel
            {
                Id = 6,
                Title = "这个是子任务1"
            };
            LiteItemModel child_2 = new LiteItemModel
            {
                Id = 7,
                Title = "这个是子任务2"
            };
            LiteItemModel child_3 = new LiteItemModel
            {
                Id = 8,
                Title = "这个是子任务3"
            };
            model.Children.Add(child_1);
            model.Children.Add(child_2);
            model.Children.Add(child_2);

            return model;
        }
Exemplo n.º 3
0
        public void TaskRelationModel_FilledBy_Task()
        {
            Task root = new Task();
            Task parent_parent = new Task();
            Task parent = new Task();
            Task current = new Task();
            Task brothers_1 = new Task();
            Task brothers_2 = new Task();
            Task child_1 = new Task();
            Task child_2 = new Task();
            Task child_3 = new Task();

            root.MockId(1);
            parent_parent.MockId(2);
            parent.MockId(3);
            current.MockId(4);
            brothers_1.MockId(5);
            brothers_2.MockId(6);
            child_1.MockId(7);
            child_2.MockId(8);
            child_3.MockId(9);

            parent_parent.Parent = root;
            parent.Parent = parent_parent;
            current.Parent = parent;
            brothers_1.Parent = parent;
            brothers_2.Parent = parent;
            child_1.Parent = current;
            child_2.Parent = current;
            child_3.Parent = current;

            root.Children = new List<Task> { parent_parent };
            parent_parent.Children = new List<Task> { parent };
            parent.Children = new List<Task> 
            {
                brothers_1,
                current,
                brothers_2
            };
            current.Children = new List<Task>
            {
                child_1,
                child_2,
                child_3
            };

            TaskRelationModel model = new TaskRelationModel();
            model.FilledBy(current);

            areEqual(model.Current, current);

            Assert.That(model.Ancestor.Count, Is.EqualTo(3));
            var first = model.Ancestor.First;
            areEqual(first.Value, root);
            var second = first.Next;
            areEqual(second.Value, parent_parent);
            var third = second.Next;
            areEqual(third.Value, parent);

            Assert.That(model.Brothers.Count, Is.EqualTo(2));
            contains(model.Brothers, brothers_1);
            contains(model.Brothers, brothers_1);

            Assert.That(model.Children.Count, Is.EqualTo(3));
            contains(model.Children, child_1);
            contains(model.Children, child_2);
            contains(model.Children, child_3);
        }