Example #1
0
        public void TestGetBalance()
        {
            CategoryModel categoryModel = new CategoryModel(); // TODO: 初始化為適當值
            Category      categoryMovie = new Category(CATEGORY_NAME_MOVIE);
            Category      categoryWork  = new Category(CATEGORY_NAME_WORK);

            categoryModel.AddCategory(categoryMovie);
            categoryModel.AddCategory(categoryWork);
            RecordModel recordModel = new RecordModel(categoryModel); // TODO: 初始化為適當值
            DateTime    now         = DateTime.Now;
            DateTime    date        = new DateTime(now.Year, now.Month, now.Day);
            Record      movieRecord = new Record(date, categoryMovie, -1000);

            recordModel.AddRecord(movieRecord);
            movieRecord = new Record(date, categoryMovie, -2000);
            recordModel.AddRecord(movieRecord);
            movieRecord = new Record(date, categoryMovie, -3000);
            recordModel.AddRecord(movieRecord);
            Record workRecord = new Record(date, categoryWork, 1000);

            recordModel.AddRecord(workRecord);
            workRecord = new Record(date, categoryWork, 2000);
            recordModel.AddRecord(workRecord);
            workRecord = new Record(date, categoryWork, 3000);
            recordModel.AddRecord(workRecord);
            workRecord = new Record(date, categoryWork, 4000);
            recordModel.AddRecord(workRecord);
            StatisticModel statisticModel = new StatisticModel(categoryModel, recordModel); // TODO: 初始化為適當值
            int            balance        = statisticModel.GetBalance(recordModel.Records);

            Assert.AreEqual(4000, balance);
        }