public async Task <IActionResult> CreateLecture(Guid id, CreateLectureCommand command)
        {
            command.Id = id;
            var result = await _mediator.Send(command);

            return(Ok(result));
        }
예제 #2
0
 public void SetUp()
 {
     _command = new CreateLectureCommand {
         Title = "title", ModuleId = "moduleId", Order = 1
     };
     _sut = new VideoCreator();
 }
        public void TitleIsNullOrEmpty_ShouldHaveError(string title)
        {
            var command = new CreateLectureCommand {
                Title = title
            };

            _sut.ShouldHaveValidationErrorFor(x => x.Title, command);
        }
        public void TitleIsOver100_ShouldHaveError()
        {
            var command = new CreateLectureCommand {
                Title = new string('*', 101)
            };

            _sut.ShouldHaveValidationErrorFor(x => x.Title, command);
        }
예제 #5
0
        public async Task ThenICreateALectureWithAnEmptyOrANullModuleId(string moduleId)
        {
            _command = new CreateLectureCommand {
                Title = "Lecture title", ModuleId = moduleId, LectureType = "Article"
            };

            _response = await _client.PostAsync(BaseUrl, Utilities.GetRequestContent(_command));
        }
        public void ModuleIdIsNullOrEmpty_ShouldHaveError(string moduleId)
        {
            var command = new CreateLectureCommand {
                ModuleId = moduleId
            };

            _sut.ShouldHaveValidationErrorFor(x => x.ModuleId, command);
        }
        public void LectureTypeIsNullOrEmpty_ShouldHaveError(string lectureType)
        {
            var command = new CreateLectureCommand {
                LectureType = lectureType
            };

            _sut.ShouldHaveValidationErrorFor(x => x.LectureType, command);
        }
예제 #8
0
 public void SetUp()
 {
     _command = new CreateLectureCommand
     {
         Title = "title", ModuleId = "moduleId", Order = 1, Content = "Content"
     };
     _sut = new ArticleCreator();
 }
예제 #9
0
        public async Task WhenICreateALectureWithATitleLengthOverCharacters(int maximumTitleLength)
        {
            _command = new CreateLectureCommand
            {
                Title = new string('*', maximumTitleLength + 1), ModuleId = "moduleId", LectureType = "Article"
            };

            _response = await _client.PostAsync(BaseUrl, Utilities.GetRequestContent(_command));
        }
예제 #10
0
        public async Task WhenICreateALectureWithAnInvalidModuleId()
        {
            _command = new CreateLectureCommand
            {
                Title = "Lecture title", ModuleId = "invalidModuleId", LectureType = "Article"
            };

            _response = await _client.PostAsync(BaseUrl, Utilities.GetRequestContent(_command));
        }
        public void ValidParameters_ShouldNotHaveError()
        {
            var command = new CreateLectureCommand
            {
                Title = "title", ModuleId = "moduleId", LectureType = "Article"
            };

            _sut.ShouldNotHaveValidationErrorFor(x => x.Title, command);
            _sut.ShouldNotHaveValidationErrorFor(x => x.ModuleId, command);
            _sut.ShouldNotHaveValidationErrorFor(x => x.LectureType, command);
        }
예제 #12
0
        public void CreateLecture_WhenCalled_CreateLecture()
        {
            var lecture = new VideoLecture("title", "moduleId", 1);
            var command = new CreateLectureCommand();

            _lectureCreatorFactory.Setup(x => x.Create(command))
            .Returns(lecture);

            var result = _sut.CreateLecture(command);

            Assert.That(result, Is.EqualTo(lecture));
        }
예제 #13
0
        public void SetUp()
        {
            _service    = new Mock <ICreateLectureService>();
            _unitOfWork = new Mock <IUnitOfWork>();

            _command = new CreateLectureCommand();

            _createdLecture = new ArticleLecture(_command.Title, _command.ModuleId, _command.Order, _command.Content);
            _service.Setup(x => x.CreateLecture(_command))
            .Returns(_createdLecture);

            _sut = new CreateLectureCommandHandler(_service.Object, _unitOfWork.Object);
        }
예제 #14
0
        public Lecture Create(CreateLectureCommand command)
        {
            var lectureType = Enumeration.FromName <LectureType>(command.LectureType);

            var lectureCreator = _lectureCreators.FirstOrDefault(x => x.LectureType.Name == lectureType.Name);

            if (lectureCreator == null)
            {
                throw new LectureCreatorNotFoundException(nameof(lectureCreator));
            }

            return(lectureCreator.Create(command));
        }
예제 #15
0
        public async Task WhenICreateALectureWithAnInvalidType()
        {
            var course = new Course("course", _instructorId, DateTime.Now);

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

            var module = new Module("module", course.Id, 1);

            _factory.CreateModule(module);

            _command = new CreateLectureCommand
            {
                Title = "Lecture title", ModuleId = module.Id, LectureType = "InvalidLectureType"
            };
            _response = await _client.PostAsync(BaseUrl, Utilities.GetRequestContent(_command));
        }
예제 #16
0
        public async Task WhenICreateALectureWithValidPropertiesAs(Table table)
        {
            var course = new Course("course", _instructorId, DateTime.Now);

            _factory.CreateCourse(course);

            var module = new Module("module", course.Id, 1);

            _factory.CreateModule(module);

            _command = new CreateLectureCommand
            {
                Title   = "lecture title", ModuleId = module.Id, LectureType = "Article",
                Content = "lecture content", Order = 1, Duration = 60
            };
            _response = await _client.PostAsync(BaseUrl, Utilities.GetRequestContent(_command));
        }
예제 #17
0
 public async Task <ActionResult <CommandResponse> > CreateLecture(CreateLectureCommand command,
                                                                   CancellationToken token)
 {
     return(Ok(await Mediator.Send(command, token)));
 }
예제 #18
0
 public Lecture Create(CreateLectureCommand command)
 {
     return(new Domain.Courses.Entities.ArticleLecture(command.Title, command.ModuleId, command.Order, command.Content));
 }
예제 #19
0
 public Lecture CreateLecture(CreateLectureCommand command)
 {
     return(_factory.Create(command));
 }
예제 #20
0
 public Lecture Create(CreateLectureCommand command)
 {
     return(new Domain.Courses.Entities.VideoLecture(command.Title, command.ModuleId, command.Order));
 }