Esempio n. 1
0
        public async Task <ActionResult> UpdateModulesOrders(UpdateLecturesOrdersCommand command,
                                                             CancellationToken token)
        {
            await Mediator.Send(command, token);

            return(NoContent());
        }
Esempio n. 2
0
        public async Task WhenIUpdateAModuleLecturesWithAnEmptyOrANullId(string moduleId)
        {
            _command = new UpdateLecturesOrdersCommand {
                ModuleId = moduleId, LecturesOrders = new LectureOrderDto[1]
            };

            _response = await _client.PutAsync(BaseUrl, Utilities.GetRequestContent(_command));
        }
Esempio n. 3
0
        public void LecturesOrdersCollectionIsNull_ShouldHaveError()
        {
            var command = new UpdateLecturesOrdersCommand {
                LecturesOrders = null
            };

            _sut.ShouldHaveValidationErrorFor(x => x.LecturesOrders, command);
        }
Esempio n. 4
0
        public void LecturesOrdersCollectionIsEmpty_ShouldHaveError()
        {
            var command = new UpdateLecturesOrdersCommand {
                LecturesOrders = new Collection <LectureOrderDto>()
            };

            _sut.ShouldHaveValidationErrorFor(x => x.LecturesOrders, command);
        }
Esempio n. 5
0
        public void ModuleIdIsEmptyOrNull_ShouldHaveError(string moduleId)
        {
            var command = new UpdateLecturesOrdersCommand {
                ModuleId = moduleId
            };

            _sut.ShouldHaveValidationErrorFor(x => x.ModuleId, command);
        }
Esempio n. 6
0
        public async Task WhenIUpdateAModuleLecturesWithAnInvalidModuleId()
        {
            _command = new UpdateLecturesOrdersCommand
            {
                ModuleId = "invalidModuleId", LecturesOrders = new LectureOrderDto[1]
            };

            _response = await _client.PutAsync(BaseUrl, Utilities.GetRequestContent(_command));
        }
Esempio n. 7
0
        public async Task WhenIUpdateAModuleLecturesWithoutSpecifyingLecturesOrders()
        {
            _command = new UpdateLecturesOrdersCommand
            {
                ModuleId = "moduleId", LecturesOrders = new List <LectureOrderDto>()
            };

            _response = await _client.PutAsync(BaseUrl, Utilities.GetRequestContent(_command));
        }
Esempio n. 8
0
        public void SetUp()
        {
            _service       = new Mock <IUpdateLecturesOrdersService>();
            _commonService = new Mock <IModulesCommonService>();
            _unitOfWork    = new Mock <IUnitOfWork>();
            _command       = new UpdateLecturesOrdersCommand();

            _sut = new UpdateLecturesOrdersCommandHandler(_service.Object, _commonService.Object,
                                                          _unitOfWork.Object);

            _lecturesToUpdateOrders = new List <Lecture>();
            _service.Setup(x => x.GetModuleLecturesFromRepo(_command.ModuleId, default))
            .ReturnsAsync(_lecturesToUpdateOrders);
        }
Esempio n. 9
0
        public async Task WhenIUpdateLecturesOrdersOfAPublishedCourse()
        {
            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 UpdateLecturesOrdersCommand {
                ModuleId = module.Id, LecturesOrders = new LectureOrderDto[1]
            };
            _response = await _client.PutAsync(BaseUrl, Utilities.GetRequestContent(_command));
        }
Esempio n. 10
0
        public void ValidParameters_ShouldNotHaveError()
        {
            var command = new UpdateLecturesOrdersCommand
            {
                ModuleId       = "moduleId",
                LecturesOrders = new[]
                {
                    new LectureOrderDto {
                        LectureId = "lecture1", Order = 1
                    },
                    new LectureOrderDto {
                        LectureId = "lecture2", Order = 2
                    }
                }
            };

            _sut.ShouldNotHaveValidationErrorFor(x => x.ModuleId, command);
            _sut.ShouldNotHaveValidationErrorFor(x => x.LecturesOrders, command);
        }
Esempio n. 11
0
        public void GivenADraftCourseAndAModuleHavingTheFollowingLecturesOrders(Table table)
        {
            var course = new Course("course", _instructorId, DateTime.Now);

            _factory.CreateCourse(course);

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

            _factory.CreateModule(module);

            var lecture1 = new ArticleLecture("lecture 1", module.Id, 1, "lecture 1 content");

            _factory.CreateLecture(lecture1);
            var lecture2 = new VideoLecture("lecture 2", module.Id, 2);

            _factory.CreateLecture(lecture2);

            _command = new UpdateLecturesOrdersCommand {
                ModuleId = module.Id
            };
            _lecturesIds = new[] { lecture1.Id, lecture2.Id };
        }