public TimeOffRequestRule(string ruleName, DTimeOffRequest timeOffRequest, IAssessor assessor, RuleType ruleType) : base(-2, timeOffRequest.employee_id, ruleName, null, assessor, ruleType, ConstraintType.TimeOffRequest, timeOffRequest) { this.Id = int.Parse(string.Format("{0}{1}{2}", timeOffRequest.employee_id, timeOffRequest.week, timeOffRequest.days[0])); this.Description = string.Format("Time off request by employee {0} for week {1} and days: {2}", timeOffRequest.employee_id, timeOffRequest.week, String.Join(",", timeOffRequest.days.ToArray())); this.TimeOffRequest = timeOffRequest; }
protected override DTimeOffRequest MockTimeOffRequest() { DTimeOffRequest timeOffRequest = new DTimeOffRequest(); // { // "employee_id": 1, // "week": 23, // "days": [ // 1, // 2, // 3 // ] //} timeOffRequest.employee_id = 1; timeOffRequest.week = 23; timeOffRequest.days = new List<int>() { 1, 2, 3 }; return timeOffRequest; }
protected override void Establish_context() { base.Establish_context(); _timeOffRequest = MockTimeOffRequest(); _weekToTest = MockWeekTotest(_timeOffRequest.week); _assessor = new EmployeeTimeOffAssessor(_timeOffRequest); _shiftRule = new TimeOffRequestRule("TIME_OFF_REQUEST", _timeOffRequest, _assessor, RuleType.SoftRule); _shiftRule.Enabled = true; }
protected override DTimeOffRequest MockTimeOffRequest() { DTimeOffRequest timeOffRequest = new DTimeOffRequest(); timeOffRequest.employee_id = 1; timeOffRequest.week = 23; timeOffRequest.days = new List<int>() { 1, 2, 3 }; return timeOffRequest; }
protected virtual IShiftRule GetShiftRuleInstance(DTimeOffRequest request, RuleType type, ConstraintType constraintType) { IShiftRule ruleInstance = null; IAssessor assessor = null; assessor = new EmployeeTimeOffAssessor(request); ruleInstance = new TimeOffRequestRule("TIME_OFF_REQUEST", request, assessor, type); if (ruleInstance != null) ruleInstance.Enabled = ruleInstance.IsRuleEnabled(); return ruleInstance; }