コード例 #1
0
        public void Get_Employee_ReturnEmployeeDto()
        {
            //arrange
            var employee = new Employee()
            {
                Id         = 1,
                Name       = "a",
                salary     = 1,
                SalaryType = new SalaryType()
                {
                    Id = 1, Name = "b"
                }
            };

            _employeeRepository.Setup(c => c.GetEmployeeById(employee.Id)).Returns(employee);

            _mapper.Setup(m => m.Map <EmployeeDto>(employee)).Returns(new EmployeeDto()
            {
                Id     = employee.Id,
                Name   = employee.Name,
                Salary = 120 * employee.salary * 12
            });
            //act
            var result = _employeeDomain.GetEmployee(employee.Id);

            //assert
            Assert.That(result, Is.InstanceOf <EmployeeDto>());
        }
コード例 #2
0
        public ViewResult Details(int?id)
        {
            var model = _employeeDomain.GetEmployee(id.Value);

            if (model != null)
            {
                return(View(model));
            }

            return(View("NotFound"));
        }