Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        public void NameLengthIsOver100_ShouldHaveError()
        {
            var command = new CreateModuleCommand {
                Name = new string('*', 101)
            };

            _sut.ShouldHaveValidationErrorFor(x => x.Name, command);
        }
Esempio n. 3
0
        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));
        }
Esempio n. 4
0
        public async Task WhenICreateAModuleWithAnInvalidCourseId()
        {
            _command = new CreateModuleCommand {
                Name = "Module name", CourseId = "invalidCourseId"
            };

            _response = await _client.PostAsync(BaseUrl, Utilities.GetRequestContent(_command));
        }
Esempio n. 5
0
        public async Task WhenICreateAModuleWithANameLengthOverCharacters(int maximumNameLength)
        {
            _command = new CreateModuleCommand {
                Name = new string('*', maximumNameLength + 1), CourseId = "courseId"
            };

            _response = await _client.PostAsync(BaseUrl, Utilities.GetRequestContent(_command));
        }
Esempio n. 6
0
        public async Task ThenICreateAModuleWithAnEmptyOrANullCourseId(string courseId)
        {
            _command = new CreateModuleCommand {
                Name = "Module name", CourseId = courseId
            };

            _response = await _client.PostAsync(BaseUrl, Utilities.GetRequestContent(_command));
        }
Esempio n. 7
0
        public async Task WhenICreateAModuleWithAnEmptyOrANull(string name)
        {
            _command = new CreateModuleCommand {
                Name = name, CourseId = "courseId"
            };

            _response = await _client.PostAsync(BaseUrl, Utilities.GetRequestContent(_command));
        }
Esempio n. 8
0
        public void NameIsNullOrEmpty_ShouldHaveError(string name)
        {
            var command = new CreateModuleCommand {
                Name = name
            };

            _sut.ShouldHaveValidationErrorFor(x => x.Name, command);
        }
Esempio n. 9
0
        public void CourseIdIsNullOrEmpty_ShouldHaveError(string courseId)
        {
            var command = new CreateModuleCommand {
                CourseId = courseId
            };

            _sut.ShouldHaveValidationErrorFor(x => x.CourseId, command);
        }
Esempio n. 10
0
        public void ValidParameters_ShouldNotHaveError()
        {
            var command = new CreateModuleCommand
            {
                Name = "name", CourseId = "courseId"
            };

            _sut.ShouldNotHaveValidationErrorFor(x => x.Name, command);
            _sut.ShouldNotHaveValidationErrorFor(x => x.CourseId, command);
        }
Esempio n. 11
0
        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));
        }
Esempio n. 12
0
        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);
        }
Esempio n. 14
0
        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();
        }
Esempio n. 15
0
 private void OnPropertyChanged(object sender, PropertyChangedEventArgs propertyChangedEventArgs)
 {
     CreateModuleCommand.RaiseCanExecuteChanged();
 }
Esempio n. 16
0
 public Module CreateModule(CreateModuleCommand command)
 {
     return(new Module(command.Name, command.CourseId, command.Order));
 }
Esempio n. 17
0
 public static Module ToModule(this CreateModuleCommand command)
 {
     return(command.MapTo <CreateModuleCommand, Module>());
 }
Esempio n. 18
0
 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)));
 }