예제 #1
0
        public async Task <int> Update([FromBody] UpdateModuleCommand updateModuleCommand)
        {
            updateModuleCommand.ModifiedBy = User.Identity.GetUserName();
            updateModuleCommand.ModifiedOn = DateTime.Now;

            return(await Mediator.Send(updateModuleCommand));
        }
        public void NameLengthOver100_ShouldHaveError()
        {
            var command = new UpdateModuleCommand {
                Name = new string('*', 101)
            };

            _sut.ShouldHaveValidationErrorFor(x => x.Name, command);
        }
        public void NameIsEmptyOrNull_ShouldHaveError(string name)
        {
            var command = new UpdateModuleCommand {
                Name = name
            };

            _sut.ShouldHaveValidationErrorFor(x => x.Name, command);
        }
        public void ModuleIdIsEmptyOrNull_ShouldHaveError(string moduleId)
        {
            var command = new UpdateModuleCommand {
                ModuleId = moduleId
            };

            _sut.ShouldHaveValidationErrorFor(x => x.ModuleId, command);
        }
예제 #5
0
        public async Task WhenIUpdateAnInvalidModuleId()
        {
            _command = new UpdateModuleCommand {
                ModuleId = "invalidModuleId", Name = "module name"
            };

            _response = await _client.PutAsync(BaseUrl, Utilities.GetRequestContent(_command));
        }
예제 #6
0
        public async Task WhenIUpdateAModuleWithAnEmptyOrANullTitle(string moduleName)
        {
            _command = new UpdateModuleCommand {
                ModuleId = "moduleId", Name = moduleName
            };

            _response = await _client.PutAsync(BaseUrl, Utilities.GetRequestContent(_command));
        }
예제 #7
0
        public async Task WhenIUpdateAModuleWithANameLengthOverCharacters(int maximumNameLength)
        {
            _command = new UpdateModuleCommand
            {
                ModuleId = "moduleId", Name = new string('*', maximumNameLength + 1)
            };

            _response = await _client.PutAsync(BaseUrl, Utilities.GetRequestContent(_command));
        }
        public void ValidParameters_ShouldNotHaveErrors()
        {
            var command = new UpdateModuleCommand
            {
                ModuleId = "moduleId", Name = "module name"
            };

            _sut.ShouldNotHaveValidationErrorFor(x => x.ModuleId, command);
            _sut.ShouldNotHaveValidationErrorFor(x => x.Name, command);
        }
예제 #9
0
        public void GivenAModuleBelongingToADraftCourseWith(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 UpdateModuleCommand {
                ModuleId = module.Id
            };
        }
        public void SetUp()
        {
            _service       = new Mock <IUpdateModuleService>();
            _commonService = new Mock <IModulesCommonService>();
            _unitOfWork    = new Mock <IUnitOfWork>();
            _command       = new UpdateModuleCommand()
            {
                ModuleId = "moduleId"
            };
            _sut = new UpdateModuleCommandHandler(_service.Object, _commonService.Object, _unitOfWork.Object);

            _moduleToUpdate = new Module("module", "courseId", 1);
            _commonService.Setup(x => x.GetModuleFromRepo(_command.ModuleId, default))
            .ReturnsAsync(_moduleToUpdate);
        }
예제 #11
0
        public async Task WhenIUpdateAModuleWhileTheCourseIsPublished()
        {
            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 UpdateModuleCommand {
                ModuleId = module.Id, Name = "module name"
            };
            _response = await _client.PutAsync(BaseUrl, Utilities.GetRequestContent(_command));
        }
        public async Task UpdateModule_Call()
        {
            //--------------    Arrange     -------------
            CommonArrangements();

            var request = new UpdateModuleRequest();
            var command = new UpdateModuleCommand();

            A.CallTo(() => _mapper.Map <UpdateModuleRequest, UpdateModuleCommand>(request)).Returns(command);


            //--------------    Act     -------------
            var resp = moduleService.UpdateModuleAsync(request);

            //--------------    Assert     -------------

            A.CallTo(() => _bus.SendAsync(command)).MustHaveHappened(Repeated.Exactly.Once);
        }
예제 #13
0
        public async Task <ActionResult> UpdateModule(UpdateModuleCommand command, CancellationToken token)
        {
            await Mediator.Send(command, token);

            return(NoContent());
        }
 public async Task <ActionResult <ModuleDto> > Put(Guid id, [FromBody] UpdateModuleCommand command)
 {
     return(Ok(await Mediator.Send(command)));
 }