public void AddCategory_WithCorrectNewName()
        {
            // Arrange
            var categoryNameToAdd = "newCategoryAdded";
            var budgetToAdd       = 13;

            // Act
            _categoryManager.AddCategory(categoryNameToAdd, budgetToAdd);

            // Assert
            var categoryName = _categoryManager.GetCategoryNameAtIndex(_categoryManager.GetCategoryCount() - 1);

            Assert.AreEqual(categoryNameToAdd, categoryName);
            Assert.AreEqual(budgetToAdd, _categoryManager.GetBudgetForCategory(categoryName));
        }
Example #2
0
 protected void btnok_Click(object sender, EventArgs e)
 {
     if (ViewState["operate"].ToString() == "edit")
     {
         #region 更新
         Categories category = CategoriesManager.GetCategoriesById(Convert.ToInt32(ViewState["categoryId"]));
         category.Name = txtbookcategory.Text.Trim();
         CategoriesManager.UpdateCategory(category);
         Panel1.Visible = false;
         BindData();
         #endregion
     }
     else
     {
         #region 添加
         CategoriesManager.AddCategory(txtbookcategory.Text);
         Panel1.Visible = false;
         BindData();
         #endregion
     }
 }