Ejemplo n.º 1
0
        public async Task <ActionResult> UpdateCourseLearningPaths(UpdateCourseLearningPathsCommand command,
                                                                   CancellationToken token)
        {
            await Mediator.Send(command, token);

            return(NoContent());
        }
Ejemplo n.º 2
0
        public void CourseIdIsEmptyOrNull_ShouldHaveError(string courseId)
        {
            var command = new UpdateCourseLearningPathsCommand {
                CourseId = courseId
            };

            _sut.ShouldHaveValidationErrorFor(x => x.CourseId, command);
        }
Ejemplo n.º 3
0
        public async Task WhenIUpdateACourseLearningPathsWithAnEmptyOrANullId(string courseId)
        {
            _command = new UpdateCourseLearningPathsCommand {
                CourseId = courseId, LearningPathsIds = new string[1]
            };

            _response = await _client.PutAsync(BaseUrl, Utilities.GetRequestContent(_command));
        }
Ejemplo n.º 4
0
        public async Task WhenIUpdateACourseLearningPathsWithAnInvalidCourseId()
        {
            _command = new UpdateCourseLearningPathsCommand
            {
                CourseId = "invalidCourseId", LearningPathsIds = new string[1]
            };

            _response = await _client.PutAsync(BaseUrl, Utilities.GetRequestContent(_command));
        }
Ejemplo n.º 5
0
        public async Task WhenIUpdateACourseLearningPathsWithoutSpecifyingLearningPathsIds()
        {
            _command = new UpdateCourseLearningPathsCommand
            {
                CourseId = "courseId", LearningPathsIds = new List <string>()
            };

            _response = await _client.PutAsync(BaseUrl, Utilities.GetRequestContent(_command));
        }
Ejemplo n.º 6
0
        public void GivenADraftCourseThatHasAnEmptyLearningPathsList(Table table)
        {
            var course = new Course("course", _instructorId, DateTime.Now);

            _factory.CreateCourse(course);

            _command = new UpdateCourseLearningPathsCommand {
                CourseId = course.Id
            };
        }
Ejemplo n.º 7
0
        public async Task WhenIUpdateACourseLearningPathsWithAnInvalidLearningPathsIds()
        {
            var course = new Course("course", _instructorId, DateTime.Now);

            _factory.CreateCourse(course);

            _command = new UpdateCourseLearningPathsCommand
            {
                CourseId = course.Id, LearningPathsIds = new[] { "invalidPathId1" }
            };
            _response = await _client.PutAsync(BaseUrl, Utilities.GetRequestContent(_command));
        }
Ejemplo n.º 8
0
        public void ValidParameters_ShouldNotHaveError()
        {
            var command = new UpdateCourseLearningPathsCommand
            {
                CourseId         = "courseId",
                LearningPathsIds = new List <string> {
                    "learningPathId"
                }
            };

            _sut.ShouldNotHaveValidationErrorFor(x => x.CourseId, command);
            _sut.ShouldNotHaveValidationErrorFor(x => x.LearningPathsIds, command);
        }
Ejemplo n.º 9
0
        public void SetUp()
        {
            _service    = new Mock <IUpdateCourseLearningPathsService>();
            _unitOfWork = new Mock <IUnitOfWork>();

            _sut = new UpdateCourseLearningPathsCommandHandler(_service.Object, _unitOfWork.Object);

            _command = new UpdateCourseLearningPathsCommand
            {
                CourseId = "courseId", LearningPathsIds = new List <string>()
            };

            _courseToUpdate = new Course("course title", "creatorId", DateTime.Now);
            _service.Setup(x => x.GetCourseFromRepo(_command.CourseId, default))
            .ReturnsAsync(_courseToUpdate);
        }
Ejemplo n.º 10
0
        public async Task WhenIUpdateTheLearningPathsOfAPublishedCourse()
        {
            var course = new Course("course", _instructorId, DateTime.Now);

            course.ChangeCourseStatus(PublishedStatus.Instance);
            _factory.CreateCourse(course);

            var learningPath = new LearningPath("developer", _organizationId);

            _factory.AddLearningPath(learningPath);

            _command = new UpdateCourseLearningPathsCommand
            {
                CourseId = course.Id, LearningPathsIds = new[] { learningPath.Id }
            };
            _response = await _client.PutAsync(BaseUrl, Utilities.GetRequestContent(_command));
        }
Ejemplo n.º 11
0
        public async Task WhenIUpdateACourseBelongingToAnOtherOrganization()
        {
            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);

            _factory.CreateCourse(course);

            _command = new UpdateCourseLearningPathsCommand {
                CourseId = course.Id, LearningPathsIds = new string[1]
            };
            _response = await _client.PutAsync(BaseUrl, Utilities.GetRequestContent(_command));
        }
Ejemplo n.º 12
0
        public void GivenADraftCourseThatHasANon_EmptyLearningPathsList(Table table)
        {
            var developer = new LearningPath("developer", _organizationId);

            _factory.AddLearningPath(developer);

            var businessAnalyst = new LearningPath("Business Analyst", _organizationId);

            _factory.AddLearningPath(businessAnalyst);

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

            course.AddLearningPath(new LearningPathCourse(developer.Id, course.Id, 1));
            course.AddLearningPath(new LearningPathCourse(businessAnalyst.Id, course.Id, 2));
            _factory.CreateCourse(course);

            _command = new UpdateCourseLearningPathsCommand {
                CourseId = course.Id
            };
            _learningPathsIds = new[] { developer.Id };
        }
Ejemplo n.º 13
0
        public void LearningPathsIdsListIsNull_ShouldHaveError()
        {
            var command = new UpdateCourseLearningPathsCommand();

            _sut.ShouldHaveValidationErrorFor(x => x.LearningPathsIds, command);
        }