public async Task ShouldNotCreateExamWithRegistrationEndDateAfterExamDate() { var examDateTime = UtcDateTime.Create(new DateTime(2020, 03, 10, 12, 00, 00, DateTimeKind.Utc)).Value; var registrationStartDate = UtcDate.Create(new DateTime(2020, 02, 08, 00, 00, 00, DateTimeKind.Utc)).Value; var registrationEndDate = UtcDate.Create(new DateTime(2020, 03, 12, 00, 00, 00, DateTimeKind.Utc)).Value; var examResult = await Exam.CreateAsync(_subjectId, _locationId, examDateTime, _capacity, registrationStartDate, registrationEndDate, _systemTimeProvider.Object, _examRepository.Object); examResult.IsSuccess.Should().BeFalse(); }
public static Result <EditExamCommand> Create(long examId, EditExamRequest request, IExamExistenceValidator examExistenceValidator) { var id = ExamId.Create(examId, examExistenceValidator); var capacity = Capacity.Create(request.Capacity) .BindErrorsTo(nameof(request.Capacity)); var registrationStartDate = UtcDate.Create(request.RegistrationStartDate) .BindErrorsTo(nameof(request.RegistrationStartDate)); var registrationEndDate = UtcDate.Create(request.RegistrationEndDate) .BindErrorsTo(nameof(request.RegistrationEndDate)); return(Result.Combine(id, capacity, registrationStartDate, registrationEndDate) .OnSuccess(() => new EditExamCommand(id.Value, capacity.Value, registrationStartDate.Value, registrationEndDate.Value))); }
public static Result <CreateExamCommand> Create(CreateExamRequest request, ISubjectExistenceValidator subjectExistenceValidator, ILocationExistenceValidator locationExistenceValidator) { var subjectId = SubjectId.Create(request.SubjectId, subjectExistenceValidator) .BindErrorsTo(nameof(request.SubjectId)); var locationId = LocationId.Create(request.LocationId, locationExistenceValidator) .BindErrorsTo(nameof(request.LocationId)); var examDateTime = UtcDateTime.Create(request.ExamDateTime) .BindErrorsTo(nameof(request.ExamDateTime)); var capacity = Capacity.Create(request.Capacity) .BindErrorsTo(nameof(request.Capacity)); var registrationStartDate = UtcDate.Create(request.RegistrationStartDate) .BindErrorsTo(nameof(request.RegistrationStartDate)); var registrationEndDate = UtcDate.Create(request.RegistrationEndDate) .BindErrorsTo(nameof(request.RegistrationEndDate)); return(Result.Combine(subjectId, locationId, examDateTime, capacity, registrationStartDate, registrationEndDate) .OnSuccess(() => new CreateExamCommand(subjectId.Value, locationId.Value, examDateTime.Value, capacity.Value, registrationStartDate.Value, registrationEndDate.Value))); }
public void ShouldReturnExpectedResult(DateTime dateTime, bool isSuccess) { var utcDateResult = UtcDate.Create(dateTime); utcDateResult.IsSuccess.Should().Be(isSuccess); }