Пример #1
0
        public void 跨年跨15個月_中間也有錢_part2()
        {
            budgets = new List <Budget>();
            budgets.Add(new Budget()
            {
                Month = "201612", BudgetPerMonth = 155
            });
            budgets.Add(new Budget()
            {
                Month = "201701", BudgetPerMonth = 124
            });
            budgets.Add(new Budget()
            {
                Month = "201705", BudgetPerMonth = 186
            });
            budgets.Add(new Budget()
            {
                Month = "201802", BudgetPerMonth = 280
            });
            BudgetCalculator calculator = new BudgetCalculator(budgets);

            var      expect    = 325;
            DateTime startDate = new DateTime(2016, 12, 31);
            DateTime endDate   = new DateTime(2018, 2, 1);
            var      actual    = calculator.TotalAmount(startDate, endDate);

            Assert.AreEqual(expect, actual);
        }
Пример #2
0
        public void 沒預算()
        {
            budgets = new List <Budget>();
            BudgetCalculator calculator = new BudgetCalculator(budgets);

            var      expect    = Decimal.Zero;
            DateTime startDate = new DateTime(2018, 6, 1);
            DateTime endDate   = new DateTime(2018, 6, 1);
            var      actual    = calculator.TotalAmount(startDate, endDate);

            Assert.AreEqual(expect, actual);
        }
Пример #3
0
        public void 例外狀態()
        {
            budgets = new List <Budget>();

            BudgetCalculator calculator = new BudgetCalculator(budgets);

            DateTime startDate = new DateTime(2018, 2, 1);
            DateTime endDate   = new DateTime(2016, 12, 31);



            Action action = () => { var actual = calculator.TotalAmount(startDate, endDate); };

            action.Should().Throw <YouShallNotPassException>();
        }
Пример #4
0
        public void 部分一個月()
        {
            budgets = new List <Budget>();
            budgets.Add(new Budget()
            {
                Month = "201804", BudgetPerMonth = 240
            });
            BudgetCalculator calculator = new BudgetCalculator(budgets);

            var      expect    = 56;
            DateTime startDate = new DateTime(2018, 4, 3);
            DateTime endDate   = new DateTime(2018, 4, 9);
            var      actual    = calculator.TotalAmount(startDate, endDate);

            Assert.AreEqual(expect, actual);
        }
Пример #5
0
        public void 跨兩個月_都有錢()
        {
            budgets = new List <Budget>();
            budgets.Add(new Budget()
            {
                Month = "201805", BudgetPerMonth = 155
            });
            budgets.Add(new Budget()
            {
                Month = "201806", BudgetPerMonth = 300
            });
            BudgetCalculator calculator = new BudgetCalculator(budgets);

            var      expect    = 15;
            DateTime startDate = new DateTime(2018, 5, 31);
            DateTime endDate   = new DateTime(2018, 6, 1);
            var      actual    = calculator.TotalAmount(startDate, endDate);

            Assert.AreEqual(expect, actual);
        }