public void ThrowsErrorWhenPersonIsInvalid() { LeaveRequest oldRequest = GenerateRequest(); LeaveRequest newRequest = oldRequest.Copy(); newRequest.PersonId = Guid.NewGuid(); var ex = Assert.Throws <UnauthorizedAccessException>(() => LeaveService.ThrowIfHrRequiredForUpdate(oldRequest, newRequest, new List <Holiday>())); ex.Message.ShouldContain("change the person"); }
public void ThrowsIfChangingApproved() { LeaveRequest oldRequest = GenerateRequest(); LeaveRequest newRequest = oldRequest.Copy(); oldRequest.Approved = false; newRequest.Approved = true; var ex = Assert.Throws <UnauthorizedAccessException>(() => LeaveService.ThrowIfHrRequiredForUpdate(oldRequest, newRequest, new List <Holiday>())); Assert.Contains("approve", ex.Message); }
public void ThrowsWhenChangingStartAndEndForOverridenDays() { LeaveRequest oldRequest = GenerateRequest(); oldRequest.OverrideDays = true; LeaveRequest newRequest = oldRequest.Copy(); newRequest.EndDate += TimeSpan.FromDays(4); var ex = Assert.Throws <UnauthorizedAccessException>(() => LeaveService.ThrowIfHrRequiredForUpdate(oldRequest, newRequest, new List <Holiday>())); Assert.Contains("modify the start or end", ex.Message); }
public void ThrowsWhenChangingDaysWhenOverriden() { LeaveRequest oldRequest = GenerateRequest(); oldRequest.OverrideDays = true; LeaveRequest newRequest = oldRequest.Copy(); newRequest.Days++; var ex = Assert.Throws <UnauthorizedAccessException>(() => LeaveService.ThrowIfHrRequiredForUpdate(oldRequest, newRequest, new List <Holiday>())); Assert.Contains("modify the length", ex.Message); }
public void AcceptMissmatchedCalculationForHalfDays() { LeaveRequest oldRequest = GenerateRequest(); //16th is a friday oldRequest.StartDate = new DateTime(2018, 3, 16); oldRequest.EndDate = new DateTime(2018, 3, 16); oldRequest.Days = oldRequest.CalculateLength(); LeaveRequest newRequest = oldRequest.Copy(); newRequest.Days = 0.5m; //does not throw LeaveService.ThrowIfHrRequiredForUpdate(oldRequest, newRequest, new List <Holiday>()); }
public void DontMissmatchedCalculationForHalfDaysOnWeekend() { LeaveRequest oldRequest = GenerateRequest(); //17th is a saturday oldRequest.StartDate = new DateTime(2018, 3, 17); oldRequest.EndDate = new DateTime(2018, 3, 17); oldRequest.Days = oldRequest.CalculateLength(); LeaveRequest newRequest = oldRequest.Copy(); newRequest.Days = 0.5m; //does not throw Assert.Throws <UnauthorizedAccessException>(() => LeaveService.ThrowIfHrRequiredForUpdate(oldRequest, newRequest, new List <Holiday>())); }
public void ThrowsErrorWhenPersonIsInvalid() { var personId = Guid.NewGuid(); LeaveRequest oldRequest = GenerateRequest(); LeaveRequest newRequest = oldRequest.Copy(); var ex = Assert.Throws <UnauthorizedAccessException>(() => _leaveService.ThrowIfHrRequiredForUpdate(oldRequest, newRequest, personId)); Assert.Contains("modify this leave request", ex.Message); personId = oldRequest.PersonId; newRequest.PersonId = Guid.NewGuid(); ex = Assert.Throws <UnauthorizedAccessException>(() => _leaveService.ThrowIfHrRequiredForUpdate(oldRequest, newRequest, personId)); Assert.Contains("modify this leave request", ex.Message); }
public void ThrowsWhenChangingTheDays() { LeaveRequest oldRequest = GenerateRequest(); LeaveRequest newRequest = oldRequest.Copy(); newRequest.Days--; var ex = Assert.Throws <UnauthorizedAccessException>(() => LeaveService.ThrowIfHrRequiredForUpdate(oldRequest, newRequest, new List <Holiday>())); Assert.Contains("must match calculated", ex.Message); newRequest.Days = newRequest.CalculateLength(); newRequest.EndDate += TimeSpan.FromDays(4); ex = Assert.Throws <UnauthorizedAccessException>(() => LeaveService.ThrowIfHrRequiredForUpdate(oldRequest, newRequest, new List <Holiday>())); Assert.Contains("must match calculated", ex.Message); }