示例#1
0
        public ResourceAction AddResourceAction(AddResourceActionCommand command)
        {
            command.Validate(true);

            var action = new ResourceAction
            {
                Name     = command.Name,
                Resource = this
            };

            this.availableActions.Add(action);
            this.AddEvent(new NewResourceActionAddedEvent(this)
            {
                Name = action.Name
            });

            return(action);
        }
示例#2
0
        public void AddResourceAction_ShouThrowDomainValidationException_WhenCommandIsInvalid(AddResourceActionCommand command, ValidationError[] errors)
        {
            var createCmd   = ApplicationResourceCmdGenerator.CreateApplicationResourceCommand;
            var newResource = ApplicationResource.Create(createCmd);

            var ex = Assert.Throws <DomainValidationException>(() => newResource.AddResourceAction(command));

            Assert.Equal(errors.Length, ex.ValidationErrors.Count());
            Assert.All(ex.ValidationErrors, e => errors.Any(er => er.Code == e.Code && er.Member == e.Member));
        }
示例#3
0
 public static IEnumerable <ValidationError> Validate(this AddResourceActionCommand command, bool throws = false)
 => validator.ValidateCommand(command, throws);