public void AddCategory() { var expected = new Category("C2", "Items"); var find = handler.GetCategoryByName("Items"); Assert.IsNull(find); handler.AddCategory(expected); find = handler.GetCategoryByName("Items"); Assert.AreEqual(expected, find); }
public void AddCategory(string categoryName) { try { MarketLog.Log("StoreCenter", "trying to add category to the store"); _admin.ValidateSystemAdmin(); MarketLog.Log("StoreCenter", " check if category name exists"); CheckIfCategoryExists(categoryName); MarketLog.Log("StoreCenter", " adding category"); if (categoryName.IsNullOrEmpty()) { Answer = new AdminAnswer(EditCategoryStatus.InvalidCategory, "The category name is empty!"); return; } Category category = new Category(categoryName); _adminDlInstacne.AddCategory(category); Answer = new AdminAnswer(EditCategoryStatus.Success, "Category " + categoryName + " added."); } catch (AdminException e) { Answer = new AdminAnswer((EditCategoryStatus)e.Status, e.GetErrorMessage()); } catch (DataException e) { Answer = new AdminAnswer((EditCategoryStatus)e.Status, e.GetErrorMessage()); } }