public void ParseContentInvalidEndOfficeHours() { _workTimeService.ParseInput($"{_path}\\Files\\InvalidEndOfficeHours"); var error = new InvalidOfficeHoursError(string.Format(ErrorMessages.InvalidEndHours, "17F0")); _errorResolver.Received().Resolve(Arg.Is <InvalidOfficeHoursError>(x => x.Code == ExitCode.InvalidOfficeHours && x.Message == error.Message)); }
private IResult ParseOfficeHours(string[] officeHours, CultureInfo provider) { if (officeHours.Length != 2) { var error = new InvalidOfficeHoursError(ErrorMessages.InvalidOfficeHours); _errorResolver.Resolve(error); return(error); } var format = "HHmm"; if (DateTime.TryParseExact(officeHours[0], format, provider, DateTimeStyles.None, out var startTime)) { OfficeHours.Start = startTime.TimeOfDay; } else { var errorStartHours = new InvalidOfficeHoursError(string.Format(ErrorMessages.InvalidStartHours, officeHours[0])); _errorResolver.Resolve(errorStartHours); return(errorStartHours); } if (DateTime.TryParseExact(officeHours[1], format, provider, DateTimeStyles.None, out var endTime)) { OfficeHours.End = endTime.TimeOfDay; } else { var errorEndHours = new InvalidOfficeHoursError(string.Format(ErrorMessages.InvalidEndHours, officeHours[1])); _errorResolver.Resolve(errorEndHours); return(errorEndHours); } return(new SuccessfulResult()); }