示例#1
0
        public ActionResult Details(int id)
        {
            var employee             = getEmployee.Execute(id);
            var employeeBenefitCosts = benefitsCalculator.CalculateEmployeeBenefitCost(employee);

            return(View(employeeBenefitCosts));
        }
            public void ThenWeShouldGetEmployeeAndCalculateBenefitCost()
            {
                fakeGetAllEmployees            = A.Fake <IGetAllEmployees>();
                fakeGetEmployee                = A.Fake <IGetEmployee>();
                fakeDeleteEmployee             = A.Fake <IDeleteEmployee>();
                fakeCreateEmployee             = A.Fake <ICreateEmployee>();
                fakeEmployeeBenefitsCalculator = A.Fake <IEmployeeBenefitsCalculator>();
                sut = new HomeController(fakeGetAllEmployees, fakeCreateEmployee, fakeGetEmployee, fakeEmployeeBenefitsCalculator, fakeDeleteEmployee);

                var employee = new Employee()
                {
                    Id = 1, Name = "Chris Brannon", NumberOfDependents = 2
                };

                A.CallTo(() => fakeGetEmployee.Execute(1)).Returns(employee);
                sut.Details(1);
                A.CallTo(() => fakeGetEmployee.Execute(1)).MustHaveHappened(Repeated.Exactly.Once);
                A.CallTo(() => fakeEmployeeBenefitsCalculator.CalculateEmployeeBenefitCost(employee)).MustHaveHappened(Repeated.Exactly.Once);
            }