Example #1
0
 //form load event
 private void LoadFormView(object sender, EventArgs e)
 {
     _ezMoneyModel    = new EZMoneyModel();
     _categoryPModel  = new CategoryPresentationModel(_ezMoneyModel);
     _recordPModel    = new RecordPresentationModel(_ezMoneyModel);
     _statisticPModel = new StatisticPresentationModel(_ezMoneyModel);
     InitCategoryView();
     InitRecordView();
     InitStatisticView();
 }
 public void TestAdd()
 {
     EZMoneyModel ezMoneyModel = new EZMoneyModel(); // TODO: 初始化為適當值
     ezMoneyModel.GetCategories().Clear();
     ezMoneyModel.GetRecords().Clear();
     CategoryPresentationModel categoryPModel = new CategoryPresentationModel(ezMoneyModel); // TODO: 初始化為適當值
     Assert.AreEqual(0, ezMoneyModel.GetCategories().Count);
     categoryPModel.Add(CATEGORY_NAME_WORK);
     Assert.AreEqual(1, ezMoneyModel.GetCategories().Count);
 }
 public void TestCancel()
 {
     EZMoneyModel ezMoneyModel = new EZMoneyModel(); // TODO: 初始化為適當值
     ezMoneyModel.GetCategories().Clear();
     ezMoneyModel.GetRecords().Clear();
     CategoryPresentationModel categoryPModel = new CategoryPresentationModel(ezMoneyModel); // TODO: 初始化為適當值
     categoryPModel.SelectCategory(0);
     Assert.IsTrue(categoryPModel.IsSelectionMode);
     categoryPModel.Cancel();
     Assert.IsFalse(categoryPModel.IsSelectionMode);
 }
 public void TestDelete()
 {
     EZMoneyModel ezMoneyModel = new EZMoneyModel(); // TODO: 初始化為適當值
     ezMoneyModel.GetCategories().Clear();
     ezMoneyModel.GetRecords().Clear();
     CategoryPresentationModel categoryPModel = new CategoryPresentationModel(ezMoneyModel); // TODO: 初始化為適當值
     categoryPModel.Add(CATEGORY_NAME_MOVIE);
     categoryPModel.Add(CATEGORY_NAME_WORK);
     Assert.AreEqual(2, ezMoneyModel.GetCategories().Count);
     categoryPModel.Delete(1, DialogResult.No);// (CATEGORY_NAME_WORK);
     Assert.AreEqual(2, ezMoneyModel.GetCategories().Count);
     categoryPModel.Delete(1, DialogResult.Yes);// (CATEGORY_NAME_WORK);
     Assert.AreEqual(1, ezMoneyModel.GetCategories().Count);
 }
 public void TestChangeTextBox()
 {
     EZMoneyModel ezMoneyModel = new EZMoneyModel(); // TODO: 初始化為適當值
     ezMoneyModel.GetCategories().Clear();
     ezMoneyModel.GetRecords().Clear();
     CategoryPresentationModel categoryPModel = new CategoryPresentationModel(ezMoneyModel); // TODO: 初始化為適當值
     categoryPModel.ChangeTextBox(CATEGORY_NAME_MOVIE);
     Assert.AreEqual(CATEGORY_NAME_MOVIE, categoryPModel.CategoryNameText);
     Category category = new Category(CATEGORY_NAME_MOVIE);
     ezMoneyModel.AddCategory(category);
     categoryPModel.SelectCategory(0);
     categoryPModel.ChangeTextBox(CATEGORY_NAME_MOVIE);
     Assert.AreEqual(false, categoryPModel.IsAddEnable);
 }
Example #6
0
 //refresh CategoryView state
 void RefreshCategoryView(CategoryPresentationModel categoryPModel)
 {
     _textBoxCategoryName.Text     = _categoryPModel.CategoryNameText;
     _buttonCategoryAdd.Enabled    = _categoryPModel.IsAddEnable;
     _buttonCategoryModify.Enabled = _categoryPModel.IsModifyEnable;
     _buttonCategoryModify.Visible = _categoryPModel.IsModifyEnable;
     _buttonCategoryDelete.Enabled = _categoryPModel.IsDeleteEnable;
     _buttonCategoryDelete.Visible = _categoryPModel.IsDeleteEnable;
     _buttonCategoryCancel.Enabled = _categoryPModel.IsCancelEnable;
     _buttonCategoryCancel.Visible = _categoryPModel.IsCancelEnable;
     _errorProviderCategory.SetError(_buttonCategoryAdd, _categoryPModel.ErrorProviderMessage);
     //if you want to visible/unvisible modification function, uncomment under line.
     //_tableLayoutPanelCategory.RowStyles[1].Height = _categoryPModel.IsSelectionMode? 40: 0;
 }
 public void TestInitializeState()
 {
     EZMoneyModel ezMoneyModel = new EZMoneyModel(); // TODO: 初始化為適當值
     ezMoneyModel.GetCategories().Clear();
     ezMoneyModel.GetRecords().Clear();
     CategoryPresentationModel categoryPModel = new CategoryPresentationModel(ezMoneyModel); // TODO: 初始化為適當值
     categoryPModel.InitializeState();
     Assert.AreEqual(false, categoryPModel.IsSelectionMode);
     Assert.AreEqual(false, categoryPModel.IsModifyEnable);
     Assert.AreEqual(false, categoryPModel.IsDeleteEnable);
     Assert.AreEqual(false, categoryPModel.IsCancelEnable);
     Assert.AreEqual(String.Empty, categoryPModel.CategoryNameText);
     Assert.AreEqual(false, categoryPModel.IsAddEnable);
 }
 public void TestSelectCategory()
 {
     EZMoneyModel ezMoneyModel = new EZMoneyModel(); // TODO: 初始化為適當值
     ezMoneyModel.GetCategories().Clear();
     ezMoneyModel.GetRecords().Clear();
     CategoryPresentationModel categoryPModel = new CategoryPresentationModel(ezMoneyModel); // TODO: 初始化為適當值
     categoryPModel.InitializeState();
     categoryPModel.SelectCategory(-1);
     Assert.AreEqual(false, categoryPModel.IsSelectionMode);
     Assert.AreEqual(false, categoryPModel.IsModifyEnable);
     Assert.AreEqual(false, categoryPModel.IsDeleteEnable);
     Assert.AreEqual(false, categoryPModel.IsCancelEnable);
     Category category = new Category(CATEGORY_NAME_WORK);
     ezMoneyModel.AddCategory(category);
     categoryPModel.SelectCategory(0);
     Assert.AreEqual(true, categoryPModel.IsSelectionMode);
     Assert.AreEqual(true, categoryPModel.IsModifyEnable);
     Assert.AreEqual(true, categoryPModel.IsDeleteEnable);
     Assert.AreEqual(true, categoryPModel.IsCancelEnable);
     Assert.AreEqual(CATEGORY_NAME_WORK, categoryPModel.CategoryNameText);
     Assert.AreEqual(false, categoryPModel.IsAddEnable);
 }
 public void TestRaiseUpdateEvent()
 {
     int raiseCount = 0;
     EZMoneyModel ezMoneyModel = new EZMoneyModel();
     ezMoneyModel.GetCategories().Clear();
     ezMoneyModel.GetRecords().Clear();
     CategoryPresentationModel categoryPModel = new CategoryPresentationModel(ezMoneyModel); // TODO: 初始化為適當值
     categoryPModel._updateEvent += delegate(CategoryPresentationModel localCategoryPModel)
     {
         raiseCount++;
     };
     categoryPModel.Add(CATEGORY_NAME_WORK);
     Assert.AreEqual(1, raiseCount);
     categoryPModel.Cancel();
     Assert.AreEqual(2, raiseCount);
 }
 public void TestModify()
 {
     EZMoneyModel ezMoneyModel = new EZMoneyModel(); // TODO: 初始化為適當值
     ezMoneyModel.GetCategories().Clear();
     ezMoneyModel.GetRecords().Clear();
     CategoryPresentationModel categoryPModel = new CategoryPresentationModel(ezMoneyModel); // TODO: 初始化為適當值
     categoryPModel.InitializeState();
     Category category = new Category(CATEGORY_NAME_WORK);
     ezMoneyModel.AddCategory(category);
     Assert.AreEqual(CATEGORY_NAME_WORK, ezMoneyModel.GetCategories()[0].CategoryName);
     categoryPModel.Modify(0, CATEGORY_NAME_MOVIE);
     Assert.AreEqual(CATEGORY_NAME_MOVIE, ezMoneyModel.GetCategories()[0].CategoryName);
 }
 public void TestIsValidCategoryAdd()
 {
     EZMoneyModel ezMoneyModel = new EZMoneyModel(); // TODO: 初始化為適當值
     ezMoneyModel.GetCategories().Clear();
     ezMoneyModel.GetRecords().Clear();
     CategoryPresentationModel categoryPModel = new CategoryPresentationModel(ezMoneyModel); // TODO: 初始化為適當值
     categoryPModel.InitializeState();
     string errorMessage = string.Empty;
     Assert.IsTrue(categoryPModel.IsValidCategoryAdd(CATEGORY_NAME_WORK, ref errorMessage));
     Assert.AreEqual(String.Empty, errorMessage);
     Assert.IsFalse(categoryPModel.IsValidCategoryAdd(String.Empty, ref errorMessage));
     Assert.AreEqual(CategoryPresentationModel.CATEGORY_NO_NAME_INFO, errorMessage);
     Category category = new Category(CATEGORY_NAME_WORK);
     ezMoneyModel.AddCategory(category);
     Assert.IsFalse(categoryPModel.IsValidCategoryAdd(CATEGORY_NAME_WORK, ref errorMessage));
     Assert.AreEqual(CategoryPresentationModel.CATEGORY_REPEAT_INFO, errorMessage);
 }
Example #12
0
 //refresh CategoryView state
 void RefreshCategoryView(CategoryPresentationModel categoryPModel)
 {
     _textBoxCategoryName.Text = _categoryPModel.CategoryNameText;
     _buttonCategoryAdd.Enabled = _categoryPModel.IsAddEnable;
     _buttonCategoryModify.Enabled = _categoryPModel.IsModifyEnable;
     _buttonCategoryModify.Visible = _categoryPModel.IsModifyEnable;
     _buttonCategoryDelete.Enabled = _categoryPModel.IsDeleteEnable;
     _buttonCategoryDelete.Visible = _categoryPModel.IsDeleteEnable;
     _buttonCategoryCancel.Enabled = _categoryPModel.IsCancelEnable;
     _buttonCategoryCancel.Visible = _categoryPModel.IsCancelEnable;
     _errorProviderCategory.SetError(_buttonCategoryAdd, _categoryPModel.ErrorProviderMessage);
     //if you want to visible/unvisible modification function, uncomment under line.
     //_tableLayoutPanelCategory.RowStyles[1].Height = _categoryPModel.IsSelectionMode? 40: 0;
 }
Example #13
0
 //form load event
 private void LoadFormView(object sender, EventArgs e)
 {
     _ezMoneyModel = new EZMoneyModel();
     _categoryPModel = new CategoryPresentationModel(_ezMoneyModel);
     _recordPModel = new RecordPresentationModel(_ezMoneyModel);
     _statisticPModel = new StatisticPresentationModel(_ezMoneyModel);
     InitCategoryView();
     InitRecordView();
     InitStatisticView();
 }