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

            return(Ok(result));
        }
Beispiel #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);
        }
        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);
        }
 public void SetUp()
 {
     _command = new CreateLectureCommand
     {
         Title = "title", ModuleId = "moduleId", Order = 1, Content = "Content"
     };
     _sut = new ArticleCreator();
 }
        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));
        }
Beispiel #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);
        }
Beispiel #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));
        }
Beispiel #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);
        }
Beispiel #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));
        }
Beispiel #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));
        }
Beispiel #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));
        }
Beispiel #17
0
 public async Task <ActionResult <CommandResponse> > CreateLecture(CreateLectureCommand command,
                                                                   CancellationToken token)
 {
     return(Ok(await Mediator.Send(command, token)));
 }
Beispiel #18
0
 public Lecture Create(CreateLectureCommand command)
 {
     return(new Domain.Courses.Entities.ArticleLecture(command.Title, command.ModuleId, command.Order, command.Content));
 }
Beispiel #19
0
 public Lecture CreateLecture(CreateLectureCommand command)
 {
     return(_factory.Create(command));
 }
Beispiel #20
0
 public Lecture Create(CreateLectureCommand command)
 {
     return(new Domain.Courses.Entities.VideoLecture(command.Title, command.ModuleId, command.Order));
 }