Exemple #1
0
        public void Create_ShoudThrowDomainValidationException_WhenCommandIsInvalid(CreateApplicationResourceCommand command, ValidationError[] errors)
        {
            var ex = Assert.Throws <DomainValidationException>(() => ApplicationResource.Create(command));

            Assert.Equal(errors.Length, ex.ValidationErrors.Count());
            Assert.All(ex.ValidationErrors, e => errors.Any(er => er.Code == e.Code && er.Member == e.Member));
        }
Exemple #2
0
        public static ApplicationResource Create(CreateApplicationResourceCommand command)
        {
            command.Validate(true);
            var created = new ApplicationResource
            {
                Name             = command.Name,
                ApplicationLevel = command.ApplicationLevel
            };

            created.AddEvent(new ApplicationResourceCreatedEvent(created));
            return(created);
        }