public static void FilledBy(this ProjectAuthorizationModel model, Project project)
 {
     model.Id = project.Id;
     model.Name = project.Name;
     model.Authorizations = new List<AuthorizationModel>();
     model.Authorizations.FilledBy(project.Authorizations);
 }
 private static void Filledby(this AbstractModel model, Project project)
 {
     model.Name = project.Name;
     model.Description = project.Description;
     model.Founder = new UserModel();
     model.Founder.FilledBy(project.Founder);
 }
        public void Top_Group()
        {
            Project root = new Project();
            Project project_1 = new Project
            {
                Parent = root
            };
            Assert.That(project_1.Root, Is.EqualTo(root));

            Project project_2 = new Project
            {
                Parent = project_1
            };
            Assert.That(project_2.Root, Is.EqualTo(root));

            Project project_3_1 = new Project
            {
                Parent = project_2
            };
            Project project_3_2 = new Project
            {
                Parent = project_2
            };
            Assert.That(project_3_1.Root, Is.EqualTo(root));
            Assert.That(project_3_2.Root, Is.EqualTo(root));
        }
        internal static void Create()
        {
            Project project_1 = new Project { Name = "成员检索项目A" };
            Project project_2 = new Project { Name = "成员检索项目B" };
            Project project_3 = new Project { Name = "成员检索项目C" };

            User user_1 = UserFactory.create("成员检索测试员-A");
            AuthorizationFactory.SetAuth(user_1, project_1, false, true, true);
            AuthorizationFactory.SetAuth(user_1, project_2, false, true, true);
            AuthorizationFactory.SetAuth(user_1, project_3, false, true, true);
            User user_2 = UserFactory.create("成员检索测试员-B");
            AuthorizationFactory.SetAuth(user_2, project_1, true, false, true);

            Task task_1 = TaskFactory.CreateTask(project_1,
                publisher: user_1,
                title: "task_1");
            task_1.CurrentStatus = Status.Accept;

            Task task_2 = TaskFactory.CreateTask(project_1,
                owner: user_1,
                title: "task_2"
                );
            task_2.CurrentStatus = Status.Accept;

            Task task_3 = TaskFactory.CreateTask(project_2,
                owner: user_1,
                title: "task_3"
                );
            task_3.CurrentStatus = Status.Accept;

            Task task_3_1 = TaskFactory.CreateTask(project_2,
                owner: user_1,
                title: "task_3_1");
            task_3_1.CurrentStatus = Status.BeginWork;

            Task task_4 = TaskFactory.CreateTask(project_3,
                owner: user_1,
                title: "task_4");
            task_4.CurrentStatus = Status.Pause;

            Task task_5 = TaskFactory.CreateTask(project_1,
                accepter: user_1,
                title: "task_5");
            task_5.CurrentStatus = Status.Remove;

            Task task_6 = TaskFactory.CreateTask(project_2,
                accepter: user_1,
                title: "task_6");
            task_6.CurrentStatus = Status.Dissent;

            Task task_7 = TaskFactory.CreateTask(project_1,
                owner: user_2,
                title: "task_7");
            task_7.CurrentStatus = Status.BeginWork;

            Task task_8 = TaskFactory.CreateTask(project_1,
                owner: user_2,
                title: "task_8");
            task_8.CurrentStatus = Status.Accept;
        }
 protected bool contains(IList<FullItemModel> model, Project project)
  {
      return model.ToList().Exists(m => (
          m.LiteItem.Id == project.Id &&
          m.LiteItem.Name == project.Name &&
          m.Description == project.Description));
  }
 internal static void Create()
 {
     founder_a = UserFactory.create("修改项目测试员-A");
     founder_b = UserFactory.create("修改项目测试员-B");
     project_a = ProjectFactory.create(founder_b, "修改测试项目-A", string.Empty, null);
     project_b = ProjectFactory.create(founder_a, "修改测试项目-B", string.Empty, null);
 }
Beispiel #7
0
 private void project_founder_previlege(User user, Project project)
 {
     Assert.That(project.Founder == user);
     Assert.That(project.Owners.Contains(user));
     Assert.That(project.Publisher.Contains(user));
     Assert.That(project.Admins.Contains(user));
 }
 private static void create_project()
 {
     User user = new User();
     not_publish_root = ProjectFactory.create(user, "无发权项目-根", string.Empty, null);
     not_publish_branch_1 = ProjectFactory.create(user, "无发权项目-枝-1", string.Empty, not_publish_root);
     not_publish_leaf = ProjectFactory.create(user, "无发权项目-叶", string.Empty, not_publish_branch_1);
     not_publish_branch_2 = ProjectFactory.create(user, "无发权项目-枝-2", string.Empty, not_publish_root);
 }
 internal static void addAuth(User user, Project project,
     bool isAdmin = true,
     bool isPublisher = true,
     bool isOwner = true)
 {
     Authorization auth = new Authorization { User = user, Project = project };
     setAuth(auth, isAdmin, isPublisher, isOwner);
     user.Authorizations.Add(auth);
 }
 internal static void createAuth(User user, Project project,
     bool isAdmin = true,
     bool isPublisher = true,
     bool isOwner = true)
 {
     Authorization auth = new Authorization { User = user, Project = project };
     user.Authorizations = new List<Authorization> { auth };
     setAuth(auth, isAdmin, isPublisher, isOwner);
 }
 private static void create_project()
 {
     renwuguanli = ProjectFactory.create(founder, "任务管理", "测试ProjectJoin页面流程用的项目", null);
     meigong = ProjectFactory.create(founder, "美工", "测试ProjectJoin页面流程用的项目", renwuguanli);
     ui = ProjectFactory.create(founder, "UI", "测试ProjectJoin页面流程用的项目", renwuguanli);
     houtai = ProjectFactory.create(founder, "后台", "测试ProjectJoin页面流程用的项目", renwuguanli);
     csharp = ProjectFactory.create(founder, "C#", "测试EdProjectJoinit页面流程用的项目", houtai);
     dba = ProjectFactory.create(founder, "DBA", "测试EdProjectJoinit页面流程用的项目", houtai);
 }
        private Authorization create_authorization(Project project)
        {
            Authorization auth = new Authorization
            {
                Project = project
            };
            Save(auth);

            return auth;
        }
        private void fill_1_level()
        {
            project_1 = new Project { Parent = root };
            project_1.MockId(1);

            project_2 = new Project { Parent = root };
            project_2.MockId(2);

            root.Children = new List<Project> { project_1, project_2 };
        }
Beispiel #14
0
        public virtual void Join(Project project)
        {
            Authorization auth = new Authorization
            {
                User = this,
                Project = project
            };

            Add(project, auth);
        }
Beispiel #15
0
        public void Create_RootProject()
        {
            Project root = new Project();
            User executor = new User();

            executor.Create(root);

            Assert.That(executor.RootProjects.Count, Is.EqualTo(1));
            Assert.That(executor.RootProjects.Contains(root));

            project_founder_previlege(executor, root);
        }
        private void fill_2_level()
        {
            project_2_1 = new Project { Parent = project_2 };
            project_2_1.MockId(21);

            project_2_2 = new Project { Parent = project_2 };
            project_2_2.MockId(22);

            project_2_3 = new Project { Parent = project_2 };
            project_2_3.MockId(23);

            project_2.Children = new List<Project> { project_2_1, project_2_2, project_2_3 };
        }
Beispiel #17
0
        public static FullItemModel FilledBy(this FullItemModel model, Project project)
        {
            model.LiteItem = new LiteItemModel();
            model.LiteItem.FilledBy(project);

            model.Description = project.Description;
            if (project.Children != null)
            {
                model.Children = new List<FullItemModel>();
                model.Children.FilledBy(project.Children);
            }

            return model;
        }
Beispiel #18
0
        public static void FilledBy(this JoinModel model, Project project, int userId)
        {
            model.Item = new FullItemModel();
            model.Children = new List<JoinModel>();

            model.Item.FilledBy(project);
            model.HasJoined = project.Authorizations.Count(x => x.User.Id == userId) > 0;
            foreach (Project childProject in project.Children)
            {
                JoinModel childModel = new JoinModel();
                childModel.FilledBy(childProject, userId);
                model.Children.Add(childModel);
            }
        }
Beispiel #19
0
        protected virtual void Add(Project project, Authorization auth)
        {
            Authorizations = Authorizations ?? new List<Authorization>();
            Authorizations.Add(auth);

            project.Authorizations = project.Authorizations ?? new List<Authorization>();
            project.Authorizations.Add(auth);

            //TODO: not sure 
            if (project.Parent != null)
            {
                project.Parent.AddChild(project);
            }
        }
Beispiel #20
0
        public virtual void Create(Project project)
        {
            Authorization auth = new Authorization
            {
                User = this,
                Project = project,
                IsFounder = true,
                IsPublisher = true,
                IsOwner = true,
                IsAdmin = true
            };

            Add(project, auth);
        }
        private void set_Projects_Hierarchy()
        {
            root = new Project();

            project_1 = new Project { Parent = root };

            project_2 = new Project { Parent = root };

            project_1_1 = new Project { Parent = project_1 };

            project_1_2 = new Project { Parent = project_1 };

            root.Children = new List<Project> { project_1, project_2 };
            project_1.Children = new List<Project> { project_1_1, project_1_2 };
        }
Beispiel #22
0
        public void Join_Project_In_Parent_Project()
        {
            User user = new User();
            Project project = new Project
            {
                Parent = new Project()
            };

            user.Join(project);

            //Assert.That(user.Projects.Count, Is.EqualTo(1));
            //Assert.That(user.Projects.Contains(project));

            Assert.That(project.Authorizations.Count, Is.EqualTo(1));
            project_newbie_previlege(project.Authorizations[0]);
        }
Beispiel #23
0
        public static void FilledBy(this SummaryModel model, Project project)
        {
            if (project.Authorizations != null)
            {
                model.Authorizations = new List<AuthorizationModel>();
                model.Authorizations.FilledBy(project.Authorizations);
            }

            if (project.Children != null)
            {
                model.Projects = new List<FullItemModel>();
                model.Projects.FilledBy(project.Children);
            }

            model.Abstract = new AbstractModel();
            model.Abstract.Filledby(project);
        }
        public void Get_Descendant_Ids()
        {
            Project project_1 = new Project();
            project_1.MockId(1);

            Project project_1_1 = new Project();
            project_1_1.MockId(11);

            Project project_1_1_1 = new Project();
            project_1_1_1.MockId(111);

            Project project_1_1_2 = new Project();
            project_1_1_2.MockId(112);

            Project project_1_1_3 = new Project();
            project_1_1_3.MockId(113);

            Project project_1_1_3_1 = new Project();
            project_1_1_3_1.MockId(1131);

            Project project_1_2 = new Project();
            project_1_2.MockId(12);

            Project project_1_3 = new Project();
            project_1_3.MockId(13);

            Project project_1_3_1 = new Project();
            project_1_3_1.MockId(131);

            project_1.Children = new List<Project> { project_1_1, project_1_2, project_1_3 };
            project_1_1.Children = new List<Project> { project_1_1_1, project_1_1_2, project_1_1_3 };
            project_1_1_3.Children = new List<Project> { project_1_1_3_1 };
            project_1_3.Children = new List<Project> { project_1_3_1 };

            IList<int> ids = project_1.GetDescendantIds();
            Assert.That(ids.Count, Is.EqualTo(9));
            Assert.That(ids.Contains(1));
            Assert.That(ids.Contains(11));
            Assert.That(ids.Contains(111));
            Assert.That(ids.Contains(112));
            Assert.That(ids.Contains(113));
            Assert.That(ids.Contains(1131));
            Assert.That(ids.Contains(12));
            Assert.That(ids.Contains(13));
            Assert.That(ids.Contains(131));
        }
        public void Get_By_Name()
        {
            string project_name_1 = "zyfei";
            string project_name_2 = "DBA";
            Project project_1 = new Project { Name = project_name_1 };
            Project project_2 = new Project { Name = project_name_2 };
            Project project_3 = new Project { Name = project_name_1 };

            IQueryable<Project> iqueryable = new List<Project> 
            {
                project_1,project_2,project_3
            }.AsQueryable();

            ProjectQuery query = new ProjectQuery(iqueryable);
            IList<Project> projects = query.GetByName(project_name_2).ToList();

            Assert.That(projects.Count, Is.EqualTo(1));
            Assert.That(projects.Contains(project_2));
        }
        internal static Task CreateTask(Project project, 
            User publisher = null,
            User accepter = null, 
            User owner = null, 
            string title = "")
        {
            Task task = new Task
            {
                Title = title,
                Project = project,
                Publisher = publisher,
                Accepter = accepter,
                Owner = owner
            };
            task.Publish();

            session.Save(task);

            return task;
        }
Beispiel #27
0
        public void Create_Project_In_Parent_Project()
        {
            Project parent_Project = new Project();
            Project new_created_project = new Project
            {
                Parent = parent_Project,
                Name = "",
                Description = ""
            };
            User executor = new User();

            executor.Create(new_created_project);

            Assert.That(executor.RootProjects.Count, Is.EqualTo(1));
            Assert.That(executor.RootProjects.Contains(parent_Project));

            Assert.That(parent_Project.Children.Count == 1);
            Assert.That(parent_Project.Children.Contains(new_created_project));

            project_founder_previlege(executor, new_created_project);
        }
        public int Create(CreateModel model, int? parentId, int userId)
        {
            User user = session.Load<User>(userId);

            Project project = new Project();
            if (parentId == null)
            {
                project.FilledBy(model, null);
            }
            else
            {
                Project parent = session.Load<Project>(parentId);
                project.FilledBy(model, parent);
            }

            user.Create(project);

            session.Save(project);

            return project.Id;
        }
        public void Project()
        {
            Project project_1 = new Project();
            Project project_2 = new Project();

            Message message_1 = create_message(project_1);
            Message message_2 = create_message(project_2);

            var result_project_id_not_value = session.Query<Message>().Project(null).ToList();
            Assert.That(result_project_id_not_value.Count, Is.EqualTo(2));
            Contains(result_project_id_not_value, message_1);
            Contains(result_project_id_not_value, message_2);

            var result_project_1 = session.Query<Message>().Project(project_1.Id).ToList();
            Assert.That(result_project_1.Count, Is.EqualTo(1));
            Assert.That(result_project_1.Single().Id, Is.EqualTo(message_1.Id));

            var result_project_2 = session.Query<Message>().Project(project_2.Id).ToList();
            Assert.That(result_project_2.Count, Is.EqualTo(1));
            Assert.That(result_project_2.Single().Id, Is.EqualTo(message_2.Id));
        }
 internal static void SetAuth(User user, Project project,
     bool isAdmin = true,
     bool isPublisher = true,
     bool isOwner = true)
 {
     if (user.Authorizations != null)
     {
         Authorization auth = user.Authorizations
             .Where(a => a.Project == project).SingleOrDefault(); 
         if ( auth == null)
         {
             addAuth(user, project, isAdmin, isPublisher, isOwner);    
         }
         else
         {
             setAuth(auth, isAdmin, isPublisher, isOwner);
         }
     }
     else
     {
         createAuth(user,project,isAdmin,isPublisher,isOwner);
     }
 }