Exemple #1
0
        public IEnumerable <IEvent> Handle(CreateTextModule command)
        {
            var textModule = TextModule.CreateNew(command, _validator);

            _textModuleRepository.Create(textModule);

            return(textModule.Events);
        }
Exemple #2
0
        public async Task <IAggregateRoot> HandleAsync(CreateTextModule command)
        {
            var textModule = TextModule.CreateNew(command, _validator);

            await _textModuleRepository.CreateAsync(textModule);

            return(textModule);
        }
Exemple #3
0
        public ICollection<IEvent> Handle(CreateTextModule command)
        {
            var textModule = TextModule.CreateNew(command, _validator);

            _textModuleRepository.Create(textModule);

            return textModule.Events;
        }
Exemple #4
0
 public void Setup()
 {
     _command = new CreateTextModule
     {
         SiteId   = Guid.NewGuid(),
         ModuleId = Guid.NewGuid(),
         Id       = Guid.NewGuid(),
         Content  = "Content"
     };
     _validatorMock = new Mock <IValidator <CreateTextModule> >();
     _validatorMock.Setup(x => x.Validate(_command)).Returns(new ValidationResult());
     _textModule = TextModule.CreateNew(_command, _validatorMock.Object);
     _event      = _textModule.Events.OfType <TextModuleCreated>().SingleOrDefault();
 }
Exemple #5
0
        public static TextModule Get()
        {
            var siteId = Guid.NewGuid();

            var createCommand = new CreateTextModule
            {
                SiteId   = siteId,
                ModuleId = Guid.NewGuid(),
                Id       = Guid.NewGuid(),
                Content  = "Content"
            };

            var createValidatorMock = new Mock <IValidator <CreateTextModule> >();

            createValidatorMock.Setup(x => x.Validate(createCommand)).Returns(new ValidationResult());

            var textModule = TextModule.CreateNew(createCommand, createValidatorMock.Object);

            var addVersionCommand = new AddVersion
            {
                SiteId               = siteId,
                ModuleId             = textModule.ModuleId,
                Id                   = textModule.Id,
                VersionId            = Guid.NewGuid(),
                Content              = "Content",
                Description          = "Description",
                Status               = TextVersionStatus.Published,
                VersionLocalisations = new List <AddVersion.VersionLocalisation>()
                {
                    new AddVersion.VersionLocalisation
                    {
                        LanguageId = Guid.NewGuid(),
                        Content    = "Localised content"
                    }
                }
            };

            _addVersionValidatorMock = new Mock <IValidator <AddVersion> >();
            _addVersionValidatorMock.Setup(x => x.Validate(addVersionCommand)).Returns(new ValidationResult());

            textModule.AddVersion(addVersionCommand, _addVersionValidatorMock.Object);

            textModule.Events.Clear();

            return(textModule);
        }