コード例 #1
0
        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();
        }
コード例 #2
0
        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)));
        }
コード例 #3
0
        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)));
        }
コード例 #4
0
        public void ShouldReturnExpectedResult(DateTime dateTime, bool isSuccess)
        {
            var utcDateResult = UtcDate.Create(dateTime);

            utcDateResult.IsSuccess.Should().Be(isSuccess);
        }