public void Update_ShoudThrowDomainValidationException_WhenCommandIsInvalid(UpdateApplicationResourceCommand command, ValidationError[] errors) { var createCmd = ApplicationResourceCmdGenerator.CreateApplicationResourceCommand; var newResource = ApplicationResource.Create(createCmd); var ex = Assert.Throws <DomainValidationException>(() => newResource.Update(command)); Assert.Equal(errors.Length, ex.ValidationErrors.Count()); Assert.All(ex.ValidationErrors, e => errors.Any(er => er.Code == e.Code && er.Member == e.Member)); }
public void Update(UpdateApplicationResourceCommand command) { command.Validate(true); this.Name = command.Name; this.ApplicationLevel = command.ApplicationLevel; this.AddEvent(new ApplicationResourceUpdatedEvent(this) { ApplicationLevel = this.ApplicationLevel, Name = this.Name }); }