Example #1
0
        public void AddEmployee()
        {
            var employeeServices = new EmployeeService(null, _mockEmployeeRepo.Object, _mockJobRolesRepo.Object, _mockUnitOfWork.Object);

            employeeServices.AddEmployee(employeeBuilder.BuildDefultEmployee());

            _mockEmployeeRepo.Verify(x => x.Attach(It.IsAny <Employee>()), Times.Once);
            _mockUnitOfWork.Verify(x => x.Commit(), Times.Once);
        }
Example #2
0
        public void AddNewEmployeeToDB()
        {
            var employeeOne = employeeBuilder.BuildDefultEmployee();
            var employeeTwo = employeeBuilder.BuildDefultEmployee();

            employeeTwo.Email = "*****@*****.**";
            var resultEmployee  = _employeeRepository.Attach(employeeOne);
            var resultEmployee2 = _employeeRepository.Attach(employeeTwo);

            var result = _unitOfWork.Commit();

            Assert.Equal(2, result);
        }
Example #3
0
        public void getFirstOrDefult()
        {
            var roleOne = jobroleBuilder.BuildDefultRole();

            _empolyeeContext.JobRoles.Add(roleOne);

            var employeeOne = employeeBuilder.BuildDefultEmployee();

            _empolyeeContext.Employees.Add(employeeOne);
            _empolyeeContext.SaveChanges();

            var resultEmployee = _employeeRepository.GetFirstOrDefult(1);

            Assert.Equal(1, resultEmployee.Id);
            Assert.Equal(employeeOne.FirstName, resultEmployee.FirstName);
            Assert.Equal("Role 1", resultEmployee.role.name);
        }