Exemplo 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);
        }
Exemplo n.º 2
0
        public void Add_a_budget_should_succeedTest()
        {
            //Arrange
            var budgetService     = Substitute.For <IBudgetService>();
            var budgetsController = new BudgetsController(budgetService);

            //Act
            budgetsController.Add("2018-11", 700);

            //Assert
            budgetService.Received()
            .Add(Arg.Is <BudgetViewModel>(budget => budget.YearMonth == "2018-11" && budget.Amount == 700));
        }
        public void TestAddAction()
        {
            //Arrange
            string yearMonth = "2018-05";

            int amount = 500;

            IBudgetsService budgetService = Substitute.For <IBudgetsService>();

            BudgetsController controller = new BudgetsController(budgetService);

            Budget budget = new Budget {
                YearMonth = yearMonth, Amount = amount
            };

            //Action
            controller.Add(budget);

            //Assert

            budgetService.Received(1)
            .AddBudget(Arg.Is <Budget>(b => b.YearMonth == yearMonth && b.Amount == amount));
        }