void ICommandHandler <CreateModuleCommand> .Handle(CreateModuleCommand command) { var domain = new Module(new ModuleId(command.ModuleId), new AppId(command.AppId), command.Title, command.Description, command.IconClass, command.Url, command.Sequence, command.DateCreated, command.DateUpdated, command.DateEnabled, command.DateDeleted); _repoModule.Save(domain); }
public void NameLengthIsOver100_ShouldHaveError() { var command = new CreateModuleCommand { Name = new string('*', 101) }; _sut.ShouldHaveValidationErrorFor(x => x.Name, command); }
public async Task <int> Create([FromBody] CreateModuleCommand createModuleCommand) { createModuleCommand.CreatedBy = User.Identity.GetUserName(); createModuleCommand.CreatedOn = DateTime.Now; createModuleCommand.Deleted = false; return(await Mediator.Send(createModuleCommand)); }
public async Task WhenICreateAModuleWithAnInvalidCourseId() { _command = new CreateModuleCommand { Name = "Module name", CourseId = "invalidCourseId" }; _response = await _client.PostAsync(BaseUrl, Utilities.GetRequestContent(_command)); }
public async Task WhenICreateAModuleWithANameLengthOverCharacters(int maximumNameLength) { _command = new CreateModuleCommand { Name = new string('*', maximumNameLength + 1), CourseId = "courseId" }; _response = await _client.PostAsync(BaseUrl, Utilities.GetRequestContent(_command)); }
public async Task ThenICreateAModuleWithAnEmptyOrANullCourseId(string courseId) { _command = new CreateModuleCommand { Name = "Module name", CourseId = courseId }; _response = await _client.PostAsync(BaseUrl, Utilities.GetRequestContent(_command)); }
public async Task WhenICreateAModuleWithAnEmptyOrANull(string name) { _command = new CreateModuleCommand { Name = name, CourseId = "courseId" }; _response = await _client.PostAsync(BaseUrl, Utilities.GetRequestContent(_command)); }
public void NameIsNullOrEmpty_ShouldHaveError(string name) { var command = new CreateModuleCommand { Name = name }; _sut.ShouldHaveValidationErrorFor(x => x.Name, command); }
public void CourseIdIsNullOrEmpty_ShouldHaveError(string courseId) { var command = new CreateModuleCommand { CourseId = courseId }; _sut.ShouldHaveValidationErrorFor(x => x.CourseId, command); }
public void ValidParameters_ShouldNotHaveError() { var command = new CreateModuleCommand { Name = "name", CourseId = "courseId" }; _sut.ShouldNotHaveValidationErrorFor(x => x.Name, command); _sut.ShouldNotHaveValidationErrorFor(x => x.CourseId, command); }
public async Task WhenICreateAModuleWithValidPropertiesAs(Table table) { var course = new Course("course", _instructorId, DateTime.Now); _factory.CreateCourse(course); _command = new CreateModuleCommand { Name = "Module name", CourseId = course.Id, Order = 1 }; _response = await _client.PostAsync(BaseUrl, Utilities.GetRequestContent(_command)); }
public async Task WhenICreateAModuleWhileTheCourseIsPublished() { var course = new Course("course", _instructorId, DateTime.Now); course.ChangeCourseStatus(PublishedStatus.Instance); _factory.CreateCourse(course); _command = new CreateModuleCommand { Name = "Module name", CourseId = course.Id }; _response = await _client.PostAsync(BaseUrl, Utilities.GetRequestContent(_command)); }
public void SetUp() { _service = new Mock <ICreateModuleService>(); _unitOfWork = new Mock <IUnitOfWork>(); _command = new CreateModuleCommand { Name = "module name", CourseId = "courseId", Order = 1 }; _sut = new CreateModuleCommandHandler(_service.Object, _unitOfWork.Object); _createdModule = new Module("module", "courseId", 1); _service.Setup(x => x.CreateModule(_command)).Returns(_createdModule); }
public void ModuleCreated() { // ARRANGE var uow = Container.Resolve <IUnitOfWork>(); var cmdDispatcher = Container.Resolve <ICommandHandlerDispatcher>(); var cmd = new CreateAppCommand("CreateModule", "CreateModule", "x", "x", "x", "x", 1); var cmd2 = new CreateModuleCommand("CreateModule", cmd.AppId, "CreateModule", "CreateModule", "CreateModule", "CreateModule", "CreateModule", 1); // ACT cmdDispatcher.Handle(cmd); cmdDispatcher.Handle(cmd2); // ASSERT uow.Commit(); }
private void OnPropertyChanged(object sender, PropertyChangedEventArgs propertyChangedEventArgs) { CreateModuleCommand.RaiseCanExecuteChanged(); }
public Module CreateModule(CreateModuleCommand command) { return(new Module(command.Name, command.CourseId, command.Order)); }
public static Module ToModule(this CreateModuleCommand command) { return(command.MapTo <CreateModuleCommand, Module>()); }
public async Task <ActionResult <CommandResponse> > CreateModule(CreateModuleCommand command, CancellationToken token) { return(Ok(await Mediator.Send(command, token))); }
public async Task <ActionResult <CreateModuleCreated> > Post([FromBody] CreateModuleCommand command) { return(Ok(await Mediator.Send(command))); }