public void TestClickDataGridView() { EZMoneyModel ezMoneyModel = new EZMoneyModel(); // TODO: 初始化為適當值 StatisticPresentationModel statisticPModel = new StatisticPresentationModel(ezMoneyModel); // TODO: 初始化為適當值 CategoryModel categoryModel = ezMoneyModel.CategoryModel; RecordModel recordModel = ezMoneyModel.RecordModel; Category category1 = new Category(CATEGORY_NAME_WORK); Category category2 = new Category(CATEGORY_NAME_MOVIE); categoryModel.AddCategory(category1); categoryModel.AddCategory(category2); DateTime date = DateTime.Now; Record record1 = new Record(date, category1, 100); Record record2 = new Record(date, category1, 200); Record record3 = new Record(date, category1, 300); Record record4 = new Record(date, category1, 400); Record record5 = new Record(date, category2, -100); Record record6 = new Record(date, category2, -200); Record record7 = new Record(date, category2, -300); recordModel.AddRecord(record1); recordModel.AddRecord(record2); recordModel.AddRecord(record3); recordModel.AddRecord(record4); recordModel.AddRecord(record5); recordModel.AddRecord(record6); recordModel.AddRecord(record7); statisticPModel.InitializeState(); BindingList<Record> records = statisticPModel.ClickDataGridView(category1); Assert.AreEqual(4, statisticPModel.RecordList.Count); Assert.AreEqual(records, statisticPModel.RecordList); statisticPModel.ChangeRadioButton(false); statisticPModel.ClickDataGridView(category2); Assert.AreEqual(3, statisticPModel.RecordList.Count); }
//constructor of statistic presentation model public StatisticPresentationModel(EZMoneyModel ezMoneyModel) { _categoryModel = ezMoneyModel.CategoryModel; _recordModel = ezMoneyModel.RecordModel; _statisticModel = ezMoneyModel.StatisticModel; InitializeState(); }
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); }
//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 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 TestChangeRadioButton() { EZMoneyModel ezMoneyModel = new EZMoneyModel(); // TODO: 初始化為適當值 StatisticPresentationModel statisticPModel = new StatisticPresentationModel(ezMoneyModel); // TODO: 初始化為適當值 statisticPModel.InitializeState(); Assert.IsTrue(statisticPModel.IsIncomeCheck); Assert.IsFalse(statisticPModel.IsExpenseCheck); bool isIncome = false; // TODO: 初始化為適當值 statisticPModel.ChangeRadioButton(isIncome); Assert.IsFalse(statisticPModel.IsIncomeCheck); Assert.IsTrue(statisticPModel.IsExpenseCheck); }
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); }
public void TestCancel() { EZMoneyModel ezMoneyModel = new EZMoneyModel(); // TODO: 初始化為適當值 RecordPresentationModel recordPModel = new RecordPresentationModel(ezMoneyModel); // TODO: 初始化為適當值 RecordModel recordModel = ezMoneyModel.RecordModel; CategoryModel categoryModel = ezMoneyModel.CategoryModel; recordModel.Records.Clear(); categoryModel.Categories.Clear(); Category category = new Category(CATEGORY_NAME_MOVIE); categoryModel.AddCategory(category); DateTime date = DateTime.Now; // TODO: 初始化為適當值 Record record = new Record(date, category, 100); recordModel.AddRecord(record); recordPModel.SelectRecord(0); Assert.AreEqual(true, recordPModel.IsSelectionMode); recordPModel.Cancel(); Assert.AreEqual(false, recordPModel.IsSelectionMode); }
public void TestAdd() { EZMoneyModel ezMoneyModel = new EZMoneyModel(); // TODO: 初始化為適當值 RecordPresentationModel recordPModel = new RecordPresentationModel(ezMoneyModel); // TODO: 初始化為適當值 RecordModel recordModel = ezMoneyModel.RecordModel; CategoryModel categoryModel = ezMoneyModel.CategoryModel; recordModel.Records.Clear(); categoryModel.Categories.Clear(); Category category = new Category(CATEGORY_NAME_MOVIE); categoryModel.AddCategory(category); DateTime date = DateTime.Now; // TODO: 初始化為適當值 int categoryIndex = 0; // TODO: 初始化為適當值 string amount = string.Empty; // TODO: 初始化為適當值 Assert.AreEqual(0, recordModel.Records.Count); recordPModel.Add(date, categoryIndex, amount); Assert.AreEqual(1, recordModel.Records.Count); recordPModel.IsIncomeCheck = false; recordPModel.IsExpenseCheck = true; recordPModel.Add(date, categoryIndex, amount); Assert.AreEqual(2, recordModel.Records.Count); }
public void TestChangeAmount() { EZMoneyModel ezMoneyModel = new EZMoneyModel(); // TODO: 初始化為適當值 RecordPresentationModel recordPModel = new RecordPresentationModel(ezMoneyModel); // TODO: 初始化為適當值 RecordModel recordModel = ezMoneyModel.RecordModel; CategoryModel categoryModel = ezMoneyModel.CategoryModel; recordModel.Records.Clear(); categoryModel.Categories.Clear(); Category category = new Category(CATEGORY_NAME_MOVIE); categoryModel.AddCategory(category); DateTime date = DateTime.Now; // TODO: 初始化為適當值 Record record = new Record(date, category, 100); recordModel.AddRecord(record); recordPModel.SelectRecord(0); const String AMOUNT_ORIGIN = "100"; const string AMOUNT_AFTER = "200"; Assert.AreEqual(AMOUNT_ORIGIN, recordPModel.Amount); recordPModel.ChangeAmount(AMOUNT_AFTER); Assert.AreEqual(AMOUNT_AFTER, recordPModel.Amount); recordPModel.IsSelectionMode = false; recordPModel.ChangeAmount(AMOUNT_AFTER); Assert.AreEqual(AMOUNT_AFTER, recordPModel.Amount); }
public void TestSetErrorProvider() { EZMoneyModel ezMoneyModel = new EZMoneyModel(); // TODO: 初始化為適當值 ezMoneyModel.GetCategories().Clear(); ezMoneyModel.GetRecords().Clear(); RecordPresentationModel recordPModel = new RecordPresentationModel(ezMoneyModel); // TODO: 初始化為適當值 Category category = new Category(CATEGORY_NAME_WORK); ezMoneyModel.AddCategory(category); recordPModel.InitializeState(); const String FIFTY = "50"; recordPModel.ChangeAmount(FIFTY); recordPModel.SetErrorProvider(); Assert.AreEqual(RecordPresentationModel.NO_SELECT_CATEGORY_INFO, recordPModel.ErrorProviderMessage); recordPModel.SelectCategory(0); Assert.AreEqual(RecordPresentationModel.EMPTY_ERROR_MESSAGE, recordPModel.ErrorProviderMessage); }
public void TestSelectRecord() { EZMoneyModel ezMoneyModel = new EZMoneyModel(); // TODO: 初始化為適當值 RecordPresentationModel recordPModel = new RecordPresentationModel(ezMoneyModel); // TODO: 初始化為適當值 RecordModel recordModel = ezMoneyModel.RecordModel; CategoryModel categoryModel = ezMoneyModel.CategoryModel; recordPModel.InitializeState(); Category category = new Category(CATEGORY_NAME_WORK); categoryModel.AddCategory(category); DateTime date = DateTime.Now; recordModel.AddRecord(date, ref category, 100); recordModel.AddRecord(date, ref category, -100); recordPModel.SelectRecord(0); Assert.AreEqual(0, recordPModel.RecordIndex); recordPModel.SelectRecord(1); Assert.AreEqual(1, recordPModel.RecordIndex); recordPModel.SelectRecord(-1); Assert.IsFalse(recordPModel.IsSelectionMode); }
public void TestSelectCategory() { EZMoneyModel ezMoneyModel = new EZMoneyModel(); // TODO: 初始化為適當值 RecordPresentationModel recordPModel = new RecordPresentationModel(ezMoneyModel); // TODO: 初始化為適當值 RecordModel recordModel = ezMoneyModel.RecordModel; CategoryModel categoryModel = ezMoneyModel.CategoryModel; recordPModel.InitializeState(); categoryModel.AddCategory(CATEGORY_NAME_WORK); recordPModel.SelectCategory(0); Assert.AreEqual(0, recordPModel.CategoryIndex); }
public void TestRaiseUpdateEvent() { EZMoneyModel ezMoneyModel = new EZMoneyModel(); // TODO: 初始化為適當值 ezMoneyModel.GetCategories().Clear(); ezMoneyModel.GetRecords().Clear(); RecordPresentationModel recordPModel = new RecordPresentationModel(ezMoneyModel); // TODO: 初始化為適當值 int raiseCount = 0; recordPModel._updateEvent += delegate(RecordPresentationModel localRecordPModel) { raiseCount++; }; DateTime date = DateTime.Now; Category category = new Category(CATEGORY_NAME_MOVIE); ezMoneyModel.AddCategory(category); const String FIFTY = "50"; recordPModel.Add(date, 0, FIFTY); Assert.AreEqual(1, raiseCount); recordPModel.Cancel(); Assert.AreEqual(2, raiseCount); }
public void TestModify() { EZMoneyModel ezMoneyModel = new EZMoneyModel(); // TODO: 初始化為適當值 RecordPresentationModel recordPModel = new RecordPresentationModel(ezMoneyModel); // TODO: 初始化為適當值 RecordModel recordModel = ezMoneyModel.RecordModel; CategoryModel categoryModel = ezMoneyModel.CategoryModel; recordModel.Records.Clear(); categoryModel.Categories.Clear(); Category category = new Category(CATEGORY_NAME_MOVIE); categoryModel.AddCategory(category); DateTime date = DateTime.Now; // TODO: 初始化為適當值 int categoryIndex = 0; // TODO: 初始化為適當值 string amount = string.Empty; // TODO: 初始化為適當值 const string NEW_AMOUNT = "100"; recordPModel.Add(date, categoryIndex, amount); Assert.AreEqual(1, recordModel.Records.Count); recordPModel.Modify(date, 0, NEW_AMOUNT); Assert.AreEqual(1, recordModel.Records.Count); Assert.AreEqual(NEW_AMOUNT, recordModel.Records[0].Amount.ToString()); recordPModel.IsIncomeCheck = false; recordPModel.IsExpenseCheck = true; recordPModel.Modify(date, 0, NEW_AMOUNT); Assert.AreEqual(1, recordModel.Records.Count); Assert.AreEqual("-" + NEW_AMOUNT, recordModel.Records[0].Amount.ToString()); }
public void TestIsValidRecordAdd() { EZMoneyModel ezMoneyModel = new EZMoneyModel(); // TODO: 初始化為適當值 RecordPresentationModel recordPModel = new RecordPresentationModel(ezMoneyModel); // TODO: 初始化為適當值 RecordModel recordModel = ezMoneyModel.RecordModel; CategoryModel categoryModel = ezMoneyModel.CategoryModel; recordPModel.InitializeState(); const string AMOUNT = "100"; const string NOT_NUMBER = "A"; string errorMessage = string.Empty; Category category = new Category(CATEGORY_NAME_MOVIE); categoryModel.AddCategory(category); Assert.IsFalse(recordPModel.IsValidRecordAdd(-1, AMOUNT, ref errorMessage)); Assert.AreEqual(RecordPresentationModel.NO_SELECT_CATEGORY_INFO, errorMessage); Assert.IsTrue(recordPModel.IsValidRecordAdd(0, AMOUNT, ref errorMessage)); Assert.AreEqual(RecordPresentationModel.EMPTY_ERROR_MESSAGE, errorMessage); Assert.IsFalse(recordPModel.IsValidRecordAdd(0, NOT_NUMBER, ref errorMessage)); Assert.AreEqual(RecordPresentationModel.TEXT_IS_NOT_NUMBER_INFO, errorMessage); }
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 TestDelete() { EZMoneyModel ezMoneyModel = new EZMoneyModel(); // TODO: 初始化為適當值 RecordPresentationModel recordPModel = new RecordPresentationModel(ezMoneyModel); // TODO: 初始化為適當值 RecordModel recordModel = ezMoneyModel.RecordModel; CategoryModel categoryModel = ezMoneyModel.CategoryModel; recordModel.Records.Clear(); categoryModel.Categories.Clear(); Category category = new Category(CATEGORY_NAME_MOVIE); categoryModel.AddCategory(category); DateTime date = DateTime.Now; // TODO: 初始化為適當值 int categoryIndex = 0; // TODO: 初始化為適當值 string amount = string.Empty; // TODO: 初始化為適當值 recordPModel.Add(date, categoryIndex, amount); Assert.AreEqual(1, recordModel.Records.Count); recordPModel.Delete(DialogResult.No); Assert.AreEqual(1, recordModel.Records.Count); recordPModel.Delete(DialogResult.Yes); Assert.AreEqual(0, recordModel.Records.Count); }
public void TestChangeIncomeCheck() { EZMoneyModel ezMoneyModel = new EZMoneyModel(); // TODO: 初始化為適當值 RecordPresentationModel recordPModel = new RecordPresentationModel(ezMoneyModel); // TODO: 初始化為適當值 RecordModel recordModel = ezMoneyModel.RecordModel; CategoryModel categoryModel = ezMoneyModel.CategoryModel; recordPModel.InitializeState(); Assert.AreEqual(true, recordPModel.IsIncomeCheck); recordPModel.ChangeIncomeCheck(false); Assert.AreEqual(false, recordPModel.IsIncomeCheck); }
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); }
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 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 TestInitializeState() { EZMoneyModel ezMoneyModel = new EZMoneyModel(); // TODO: 初始化為適當值 RecordPresentationModel recordPModel = new RecordPresentationModel(ezMoneyModel); // TODO: 初始化為適當值 RecordModel recordModel = ezMoneyModel.RecordModel; CategoryModel categoryModel = ezMoneyModel.CategoryModel; recordPModel.InitializeState(); Assert.AreEqual(false, recordPModel.IsSelectionMode); Assert.AreEqual(false, recordPModel.IsModifyEnable); Assert.AreEqual(false, recordPModel.IsDeleteEnable); Assert.AreEqual(false, recordPModel.IsCancelEnable); }
public void TestEnterTabPageStatistic() { EZMoneyModel ezMoneyModel = new EZMoneyModel(); // TODO: 初始化為適當值 StatisticPresentationModel statisticPModel = new StatisticPresentationModel(ezMoneyModel); // TODO: 初始化為適當值 statisticPModel.InitializeState(); Assert.IsTrue(statisticPModel.IsIncomeCheck); Assert.IsFalse(statisticPModel.IsExpenseCheck); const string ZERO = "0"; Assert.AreEqual(ZERO, statisticPModel.Income); Assert.AreEqual(ZERO, statisticPModel.Expense); Assert.AreEqual(ZERO, statisticPModel.Balance); statisticPModel.EnterTabPageStatistic(); Assert.AreEqual(ZERO, statisticPModel.Income); Assert.AreEqual(ZERO, statisticPModel.Expense); Assert.AreEqual(ZERO, statisticPModel.Balance); }
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); }
//category presentation model constructor public CategoryPresentationModel(EZMoneyModel ezMoneyModel) { _categoryModel = ezMoneyModel.CategoryModel; _recordModel = ezMoneyModel.RecordModel; InitializeState(); }