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 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 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 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); }