Пример #1
0
 public void TestCreation1()
 {
     Category TestCategory = new Category(_Name, _Id);
     Assert.IsNotNull(TestCategory);
     Assert.AreEqual(_Id, TestCategory.Id);
     Assert.AreEqual(_Name, TestCategory.Name);
 }
Пример #2
0
 public void TestCreation()
 {
     Category TestCategory = new Category(_ProjectId, _Name);
     Assert.IsNotNull(TestCategory);
     Assert.AreEqual(_ProjectId, TestCategory.ProjectId);
     Assert.AreEqual(_Name, TestCategory.Name);
 }
Пример #3
0
 public void TestCreation2()
 {
     Category TestCategory = new Category( _Name, _Id, _ChildCount);
     Assert.IsNotNull(TestCategory);
     Assert.AreEqual(_Id, TestCategory.Id);
     Assert.AreEqual(_Name, TestCategory.Name);
     Assert.AreEqual(_ChildCount, TestCategory.ChildCount);
 }
Пример #4
0
 public void TestCreation3()
 {
     Category TestCategory = new Category(_ProjectId,_ParentCategoryId,_Name, _ChildCount);
     Assert.IsNotNull(TestCategory);
     Assert.AreEqual(_ProjectId, TestCategory.ProjectId);
     Assert.AreEqual(_ParentCategoryId ,TestCategory.ParentCategoryId);
     Assert.AreEqual(_Name, TestCategory.Name);
     Assert.AreEqual(_ChildCount, TestCategory.ChildCount);
 }
Пример #5
0
        public int AddCategory(string projectId, string name, string parentCategoryId)
        {
            if (string.IsNullOrEmpty(projectId))
                throw new ArgumentNullException("projectId");
            if (string.IsNullOrEmpty(name))
                throw new ArgumentNullException("name");
            if (string.IsNullOrEmpty(parentCategoryId))
                throw new ArgumentNullException("parentCategoryId");

            string UserName = Thread.CurrentPrincipal.Identity.Name;

            if (!ITUser.IsInRole(UserName, Convert.ToInt32(projectId), Globals.ProjectAdminRole) && !ITUser.IsInRole(UserName, 0, Globals.SuperUserRole))
                throw new UnauthorizedAccessException(Logging.GetErrorMessageResource("AccessDenied"));

            Category c = new Category(Convert.ToInt32(projectId),Convert.ToInt32(parentCategoryId), name, 0);
            c.Save();
            return c.Id;
        }
        /// <summary>
        /// Handles the Click event of the OkButton control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void OkButton_Click(object sender, EventArgs e)
        {
            int OldCategoryId = 0;
            if(!string.IsNullOrEmpty(HiddenField1.Value))
                OldCategoryId = Convert.ToInt32(HiddenField1.Value);

            if (OldCategoryId != 0)
            {
                List<QueryClause> queryClauses = new List<QueryClause>();
                QueryClause q = new QueryClause("AND", "IssueCategoryId", "=", HiddenField1.Value, SqlDbType.Int, false);
                queryClauses.Add(q);

                List<Issue> issues = Issue.PerformQuery(ProjectId, queryClauses);
                if (RadioButton1.Checked) //delete category
                {
                    //delete all issues first
                    foreach (Issue issue in issues)
                        Issue.DeleteIssue(issue.Id);

                    //delete the category.
                    Category.DeleteCategory(OldCategoryId);
                }

                if (RadioButton2.Checked) //reassign issues to existing category.
                {
                    if (DropCategory.SelectedValue == 0)
                    {
                        Message1.ShowErrorMessage(GetLocalResourceObject("NoCategorySelected").ToString());
                        return;
                    }
                    if (OldCategoryId == DropCategory.SelectedValue)
                    {
                        Message1.ShowErrorMessage(GetLocalResourceObject("SameCategorySelected").ToString());
                        return;
                    }

                    foreach (Issue issue in issues)
                    {
                        issue.CategoryName = DropCategory.SelectedText;
                        issue.CategoryId = DropCategory.SelectedValue;
                        issue.Save();
                    }

                    //delete the category.
                    Category.DeleteCategory(OldCategoryId);
                }

                //assign new category
                if (RadioButton3.Checked)
                {
                    if(string.IsNullOrEmpty(NewCategoryTextBox.Text))
                    {
                        Message1.ShowErrorMessage(GetLocalResourceObject("NewCategoryNotEntered").ToString());
                        return;
                    }
                    Category c = new Category(ProjectId, 0, NewCategoryTextBox.Text, 0);
                    c.Save();
                    foreach (Issue issue in issues)
                    {
                        issue.CategoryName = NewCategoryTextBox.Text;
                        issue.CategoryId = c.Id;
                        issue.Save();
                    }
                    //delete the category.
                    Category.DeleteCategory(OldCategoryId);

                }
            }
            else
            {
                Message1.ShowErrorMessage(GetLocalResourceObject("CannotDeleteRootCategory").ToString());
                return;
            }
        }
Пример #7
0
 public void TestParentCategoryIdProperty()
 {
     Category c = new Category(_ProjectId, _Name);
     c.ParentCategoryId = _ParentCategoryId;
     Assert.AreEqual(_ParentCategoryId, c.ParentCategoryId);
 }
Пример #8
0
 public void TestNameProperty()
 {
     Category c = new Category(_ProjectId, _Name);
     c.Name = "NewName";
     Assert.AreEqual("NewName", c.Name);
 }