Beispiel #1
0
        public async Task WhenIEditAnInvalidCourseId()
        {
            _command = new DraftCourseCommand {
                CourseId = "invalidCourseId"
            };

            _response = await _client.PutAsync(BaseUrl, Utilities.GetRequestContent(_command));
        }
Beispiel #2
0
        public async Task WhenIEditACourseWithAnEmptyOrANull(string courseId)
        {
            _command = new DraftCourseCommand {
                CourseId = courseId
            };

            _response = await _client.PutAsync(BaseUrl, Utilities.GetRequestContent(_command));
        }
Beispiel #3
0
        public void ValidCourseId_ShouldNotHaveError()
        {
            var command = new DraftCourseCommand {
                CourseId = "courseId"
            };

            _sut.ShouldNotHaveValidationErrorFor(x => x.CourseId, command);
        }
Beispiel #4
0
        public void EmptyOrNullCourseId_ShouldHaveError(string courseId)
        {
            var command = new DraftCourseCommand {
                CourseId = courseId
            };

            _sut.ShouldHaveValidationErrorFor(x => x.CourseId, command);
        }
Beispiel #5
0
        public void GivenACourseBelongingToMyOrganization()
        {
            var course = new Course("course", _instructorId, DateTime.Now);

            course.ChangeCourseStatus(UnpublishedStatus.Instance);
            _command = new DraftCourseCommand {
                CourseId = course.Id
            };
            _factory.CreateCourse(course);
        }
Beispiel #6
0
        public void SetUp()
        {
            _service       = new Mock <IDraftCourseService>();
            _commonService = new Mock <ICoursesCommonService>();
            _unitOfWork    = new Mock <IUnitOfWork>();
            _command       = new DraftCourseCommand {
                CourseId = "courseId"
            };
            _sut = new DraftCourseCommandHandler(_service.Object, _commonService.Object, _unitOfWork.Object);


            _courseToDraft = new Course("name", "creatorId", DateTime.Now);
            _commonService.Setup(x => x.GetCourseFromRepo(_command.CourseId, default))
            .ReturnsAsync(_courseToDraft);
        }
Beispiel #7
0
        public async Task WhenIEditACourseBelongingToAnOtherOrganization()
        {
            var otherOrganization = new Organization("other organization", SubscriptionPlans.Free);

            _factory.CreateOrganization(otherOrganization);

            var otherInstructor = new User("*****@*****.**", otherOrganization.Id);

            _factory.CreateUser(otherInstructor);

            var course = new Course("course", otherInstructor.Id, DateTime.Now);

            _command = new DraftCourseCommand {
                CourseId = course.Id
            };
            _factory.CreateCourse(course);

            _response = await _client.PutAsync(BaseUrl, Utilities.GetRequestContent(_command));
        }
Beispiel #8
0
        public async Task <ActionResult> DraftCourse(DraftCourseCommand command, CancellationToken token)
        {
            await Mediator.Send(command, token);

            return(NoContent());
        }