public Employee WithPaidTimeOffPolicy(PaidTimeOffPolicy paidTimeOffPolicy) { if (paidTimeOffPolicy.EmployeeLevel != EmployeeLevel) { throw new EmployeeException("Invalid paid time off PaidTimeOffPolicy assigned to employee. The PaidTimeOffPolicy EmployeeLevel must be the same as the employee's EmployeeLevel."); } var e = CreateShallowCopy(); e.PaidTimeOffPolicy = paidTimeOffPolicy; return(e); }
public void MapToDbEntity_WorksAsExpected() { var e = new PaidTimeOffPolicy(true, 6, true, 55.0m, "HELLO", 10.0M) { Id = 67 }; var d = mapper.MapToDbEntity(e); Assert.Equal(e.Id, d.Id); Assert.Equal(e.AllowsUnlimitedPto, d.AllowsUnlimitedPto); Assert.Equal(e.EmployeeLevel, d.EmployeeLevel); Assert.Equal(e.IsDefaultForEmployeeLevel, d.IsDefaultForEmployeeLevel); Assert.Equal(e.MaxPtoHours, d.MaxPtoHours); Assert.Equal(e.Name, d.Name); Assert.Equal(e.PtoAccrualRate, d.PtoAccrualRate); }
public Employee( DateTime dateHired, DateTime dateOfBirth, int employeeLevel, string firstName, Gender gender, Address homeAddress, string lastName, PaidTimeOffPolicy paidTimeOffPolicy, Money salary, SocialSecurityNumber socialSecurityNumber, DateTime?dateExited = default, string middleName = default, decimal?ptoHoursRemaining = default, IReadOnlyList <Employee> subordinates = default ) { if (employeeLevel <= 0) { throw new ArgumentOutOfRangeException(nameof(employeeLevel)); } DateExited = dateExited; DateHired = dateHired; DateOfBirth = dateOfBirth; EmployeeLevel = employeeLevel; FirstName = firstName ?? throw new ArgumentNullException(nameof(firstName)); Gender = gender; HomeAddress = homeAddress ?? throw new ArgumentNullException(nameof(homeAddress)); LastName = lastName ?? throw new ArgumentNullException(nameof(lastName)); MiddleName = middleName ?? ""; PaidTimeOffPolicy = paidTimeOffPolicy; PtoHoursRemaining = ptoHoursRemaining; Salary = salary ?? throw new ArgumentNullException(nameof(salary)); if (salary.Amount <= 0.0m) { throw new ArgumentOutOfRangeException(nameof(salary)); } SocialSecurityNumber = socialSecurityNumber ?? throw new ArgumentNullException(nameof(socialSecurityNumber)); Subordinates = (subordinates ?? Enumerable.Empty <Employee>()).ToList(); CrossLinkSubordinates(); }
public void Map_WorksAsExpected() { var p = new PaidTimeOffPolicy { AllowsUnlimitedPto = true, EmployeeLevel = 6, IsDefaultForEmployeeLevel = true, MaxPtoHours = 55.0m, Name = "HELLO", PtoAccrualRate = 10.0M, Id = 67 }; var d = mapper.Map(p); Assert.Equal(p.Id, d.Id); Assert.Equal(p.AllowsUnlimitedPto, d.AllowsUnlimitedPto); Assert.Equal(p.EmployeeLevel, d.EmployeeLevel); Assert.Equal(p.IsDefaultForEmployeeLevel, d.IsDefaultForEmployeeLevel); Assert.Equal(p.MaxPtoHours, d.MaxPtoHours); Assert.Equal(p.Name, d.Name); Assert.Equal(p.PtoAccrualRate, d.PtoAccrualRate); }