Exemplo n.º 1
0
        public async Task <ActionResult> AddCoursesToLearningPaths(AddCoursesToLearningPathCommand command,
                                                                   CancellationToken token)
        {
            await Mediator.Send(command, token);

            return(NoContent());
        }
        public void CoursesIdsListIsNull_ShouldHaveError(List <string> coursesIds)
        {
            var command = new AddCoursesToLearningPathCommand {
                CoursesIds = coursesIds
            };

            _sut.ShouldHaveValidationErrorFor(x => x.CoursesIds, command);
        }
        public void LearningPathIdIsValid_ShouldNotHaveError()
        {
            var command = new AddCoursesToLearningPathCommand {
                LearningPathId = "learningPathId"
            };

            _sut.ShouldNotHaveValidationErrorFor(x => x.LearningPathId, command);
        }
        public void LearningPathIdIsEmptyOrNull_ShouldHaveError(string learningPathId)
        {
            var command = new AddCoursesToLearningPathCommand {
                LearningPathId = learningPathId
            };

            _sut.ShouldHaveValidationErrorFor(x => x.LearningPathId, command);
        }
        public void CoursesIdsListIsValid_ShouldNotHaveError()
        {
            var command = new AddCoursesToLearningPathCommand {
                CoursesIds = new List <string> {
                    "courseId"
                }
            };

            _sut.ShouldNotHaveValidationErrorFor(x => x.CoursesIds, command);
        }
        public void SetUp()
        {
            _service    = new Mock <IAddCoursesToLearningPathService>();
            _unitOfWork = new Mock <IUnitOfWork>();
            _sut        = new AddCoursesToLearningPathCommandHandler(_service.Object, _unitOfWork.Object);

            _command = new AddCoursesToLearningPathCommand {
                CoursesIds = new List <string> {
                    "courseId"
                }
            };

            _learningPathToUpdate = new LearningPath("name", "organizationId");
            _service.Setup(x => x.GetLearningPathFromRepo(_command.LearningPathId, default))
            .ReturnsAsync(_learningPathToUpdate);
        }