Ejemplo n.º 1
0
        public void AddTest_should_add_a_budget_record()
        {
            var service = Substitute.For <IBudgetService>();
            var target  = new BudgetsController(service);

            var model = new BudgetModels();

            target.Add(model);

            service.Received().Save(model);
        }
Ejemplo n.º 2
0
        public void Save(BudgetModels model)
        {
            using (var dbcontext = new NorthwindEntitiesProd())
            {
                var budget = new Budgets {
                    Amount = model.Amount, YearMonth = model.Month
                };
                dbcontext.Budgets.Add(budget);

                dbcontext.SaveChanges();
            }
        }
Ejemplo n.º 3
0
        public void SaveTest_for_integration_test()
        {
            var model = new BudgetModels()
            {
                Amount = 100, Month = "2017-11"
            };
            var target = new BudgetService();

            target.Save(model);

            using (var dbcontext = new NorthwindEntities())
            {
                var o = dbcontext.Budgets
                        .Find("2017-11");
                var expected = new BudgetWebApp.Tests.DataModels.Budgets {
                    Amount = 100, YearMonth = "2017-11"
                };
                expected.ToExpectedObject().ShouldEqual(o);
            }
        }
Ejemplo n.º 4
0
 public ActionResult Add(BudgetModels model)
 {
     //todo, model沒有內容
     this.service.Save(model);
     return(View(model));
 }