Exemplo n.º 1
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));
 }
 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);
 }
 private static void create_users()
 {
     addresser = UserFactory.create("发布留言测试人");
     addressee_A = UserFactory.create("收信人-A");
     addressee_B = UserFactory.create("收信人-B");
     addressee_C = UserFactory.create("收信人-C");
 }
Exemplo n.º 4
0
        public void BeginWork_Not_Affect_Parent()
        {
            #region preparation

            Task task = get_task_with_parents();
            task.Owner = new User();

            Task parent = task.Parent;

            Task grand_parent = task.Parent.Parent;
            User grand_parent_owner = new User();
            grand_parent.Owner = grand_parent_owner;

            #endregion

            #region will not affect its parent

            task.BeginWork();

            task.has_begin();

            Assert.That(parent.CurrentStatus, Is.Not.EqualTo(Status.BeginWork));
            Assert.That(grand_parent.CurrentStatus, Is.Not.EqualTo(Status.BeginWork));

            #endregion
        }
Exemplo n.º 5
0
 private static void create_users()
 {
     addressee = UserFactory.create("接收留言测试人");
     addresser_A = UserFactory.create("留言人-A");
     addresser_B = UserFactory.create("留言人-B");
     addresser_C = UserFactory.create("留言人-C");
 }
Exemplo n.º 6
0
 private static void create_user()
 {
     admin = UserFactory.create("任务列表测试管理员");
     publisher = UserFactory.create("任务列表测试发布人");
     owner = UserFactory.create("任务列表测试承接人");
     accepter = UserFactory.create("任务列表测试验收人");
 }
Exemplo n.º 7
0
        public void BeginEdit()
        {
            Task task = new Task();
            User user_1 = new User();

            task.BeginEdit(user_1);
            Assert.That(task.EditingBy, Is.EqualTo(user_1));
        }
 private static void create_users()
 {
     publish_a = UserFactory.create("发布人A");
     publish_b = UserFactory.create("发布人B");
     own_a = UserFactory.create("承接人A");
     third_a = UserFactory.create("第三人A");
     third_b = UserFactory.create("第三人B");
 }
 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 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);
 }
Exemplo n.º 11
0
        public void EndEdit()
        {
            Task task = new Task();
            User user_1 = new User();

            task.BeginEdit(user_1);
            task.EndEdit();
            Assert.That(task.EditingBy, Is.Null);
        }
 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);
 }
Exemplo n.º 13
0
        public void RootProjects()
        {
            User user_1 = new User();
            User user_2 = new User();
            Project project_1 = new Project();
            Project project_1_1 = new Project { Parent = project_1 };
            Project project_1_2 = new Project { Parent = project_1 };
            Project project_2 = new Project();
            Project project_2_1 = new Project { Parent = project_2 };
            Project project_3 = new Project();

            Authorization auth_1 = new Authorization
            {
                User = user_1,
                Project = project_1,
                IsFounder = true
            };
            Authorization auth_1_1 = new Authorization
            {
                User = user_1,
                Project = project_1_1,
                IsFounder = false
            };
            Authorization auth_1_2 = new Authorization
            {
                User = user_1,
                Project = project_1_2,
                IsFounder = true
            };
            user_1.Authorizations = new List<Authorization>();
            user_1.Authorizations.Add(auth_1);
            user_1.Authorizations.Add(auth_1_1);
            user_1.Authorizations.Add(auth_1_2);

            Authorization auth_2_1 = new Authorization
            {
                User = user_2,
                Project = project_2_1
            };
            Authorization auth_3 = new Authorization
            {
                User = user_2,
                Project = project_3
            };
            user_2.Authorizations = new List<Authorization>();
            user_2.Authorizations.Add(auth_2_1);
            user_2.Authorizations.Add(auth_3);

            //only the root projects are included
            Assert.That(user_1.RootProjects.Count, Is.EqualTo(1));
            Assert.That(user_1.RootProjects.Contains(project_1));

            Assert.That(user_2.RootProjects.Count, Is.EqualTo(2));
            Assert.That(user_2.RootProjects.Contains(project_2));
            Assert.That(user_2.RootProjects.Contains(project_3));
        }
Exemplo n.º 14
0
        public static UserModel FilledBy(this UserModel model, User user)
        {
            model.Id = user.Id;
            model.Name = user.Name;
            model.AuthCode = user.AuthenticationCode;
            model.HasLogon = true;
            model.IsAdmin = user.IsAdmin;
            model.HasJoinedProject = !user.Authorizations.IsNullOrEmpty();

            return model;
        }
Exemplo n.º 15
0
 internal static User create(string username)
 {
     User user = new User
     {
         Name = username,
         Password = "******".Md5Encypt(),
         AuthenticationCode = RandomGenerator.GetNumbers(6)
     };
     session.Save(user);
     return user;
 }
Exemplo n.º 16
0
        public int Do(RegisterModel model)
        {
            User user = new User
            {
                Name = model.UserName,
                Password = model.Password.Md5Encypt(),
                AuthenticationCode = RandomGenerator.GetNumbers(6)
            };
            session.Save(user);

            return user.Id;
        }
Exemplo n.º 17
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);
        }
Exemplo n.º 18
0
        internal static void Create()
        {
            xinqing = create("心晴");
            zyfei = create("自由飞");
            yezi = create("叶子");
            kejigaibianshenhuo = create("科技改变生活");
            jishuzai = create("技术宅");

            yongbaosijie = create("拥抱世界");
            jikemengxiang = create("极客梦想");
            meilunmeihuan = create("美轮美奂");
            zhangsan = create("张三");
            lisi = create("李四");
            wutuandui = create("无团队");
        }
Exemplo n.º 19
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]);
        }
Exemplo n.º 20
0
        public void BeginWork_With_Parent()
        {
            #region preparation

            Task task = get_task_with_parents();
            task.Owner = new User();

            Task parent = task.Parent;
            parent.IsVirtual = true;

            Task grand_parent = task.Parent.Parent;
            grand_parent.IsVirtual = true;
            User grand_parent_owner = new User();
            grand_parent.Owner = grand_parent_owner;

            #endregion

            #region the first time the task begin

            task.BeginWork();

            task.has_begin();

            parent.has_begin(Constants.CommentAutoBegin);
            Assert.That(parent.Owner, Is.EqualTo(task.Owner));
            has_auto_own(parent);

            grand_parent.has_begin(Constants.CommentAutoBegin);
            //the owner will not change because it had one before
            Assert.That(grand_parent.Owner, Is.EqualTo(grand_parent_owner));

            #endregion

            #region a second time the task's brother begin

            Task brother = new Task();
            parent.AddChild(brother);

            SystemTime.SetDateTime(now.AddMinutes(23));
            brother.BeginWork();

            Assert.That(parent.LatestUpdateTime, Is.EqualTo(now));

            #endregion
        }
Exemplo n.º 21
0
        public void Send()
        {
            User addresser = new User();
            User addressee = new User();

            Message message = new Message
            {
                Addresser = addresser,
                Addressee = addressee
            };

            Assert.That(addresser.MessagesFromMe.IsNullOrEmpty(), Is.True);
            Assert.That(addressee.MessagesToMe.IsNullOrEmpty(), Is.True);

            message.Send();

            Assert.That(addresser.MessagesFromMe.Count, Is.EqualTo(1));
            Assert.That(addressee.MessagesToMe.Count, Is.EqualTo(1));
        }
Exemplo n.º 22
0
        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;
        }
Exemplo n.º 23
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);
        }
 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);
     }
 }
Exemplo n.º 25
0
        public void Not_Send()
        {
            Message message_empty = new Message
            {
                Addresser = null,
                Addressee = null
            };

            message_empty.Send();             //no exception is threw out

            User addresser = new User();            
            Message message_no_addressee = new Message
            {
                Addresser = addresser,
                Addressee = null
            };

            message_no_addressee.Send();

            //need not record into MessageFromMe since no addressee
            Assert.That(addresser.MessagesFromMe.Count, Is.EqualTo(1));

            
            User addressee = new User();
            Message message_no_addresser = new Message
            {
                Addresser = null,
                Addressee = addressee
            };
            Assert.That(addressee.MessagesToMe.IsNullOrEmpty(), Is.True);

            message_no_addresser.Send();

            //only record in MessagesToMe
            Assert.That(addressee.MessagesToMe.Count, Is.EqualTo(1));              
        }
 private static void create_user()
 {
     publisher = UserFactory.create("任务关系测试人");
 }
Exemplo n.º 27
0
 private string getName(User user)
 {
     if (user == null)
     {
         return "未指定";
     }
     else
     {
         return user.Name;
     }
 }
Exemplo n.º 28
0
        public void IsAdmin()
        {
            User user = new User();
            user.Authorizations = new List<Authorization>();
            Project project_1 = new Project();
            Project project_1_1 = new Project();
            Project project_2 = new Project();

            Authorization auth_1 = new Authorization { User = user, Project = project_1 };
            user.Authorizations.Add(auth_1);

            Assert.That(user.IsAdmin, Is.False);

            Authorization auth_2 = new Authorization { User = user, Project = project_2, IsAdmin = true };
            user.Authorizations.Add(auth_2);

            Assert.That(user.IsAdmin, Is.True);

            Authorization auth_1_1 = new Authorization { User = user, Project = project_1_1, IsAdmin = true };
            user.Authorizations.Add(auth_1_1);

            Assert.That(user.IsAdmin, Is.True);

            user.Authorizations.Remove(auth_2);
            Assert.That(user.IsAdmin, Is.True);

            user.Authorizations.Remove(auth_1_1);
            Assert.That(user.IsAdmin, Is.False);
        }
 private static void create_users()
 {
     founder = UserFactory.create("项目创始人");
     project_join_test_user = UserFactory.create("项目加入测试人员");
 }
Exemplo n.º 30
0
        public void Accept_When_Owner_Is_Accepter()
        {
            User user = new User();
            Task task = new Task
            {
                Owner = user,
                Accepter = user
            };
            task.BeginWork();
            task.Complete();

            task.has_accept(Constants.CommentAutoAcceptForOwnerIsAccepter);
        }