There are plenty of hacks you could do so that it does not run when
you are running your unit tests...
One way would be to create a new validation registry that mimics the
behavior of CachedValidationRegistry, but ignores that particular
validator. It is a little bit of cut and paste work becaused
CachedValidationRegistry's methods are not virtual. Then in your test
setup, you can do:
controller.Validator = new ValidatorRunner(new
MyValidationRegistry());
Another way would be to override the ValidateIsUniqueAttribute class
and have the constructor check a variable to see if if should create
the IsUniqueValidator or not. Pseudo code:
MyValidateIsUniqueAttribute : ValidateIsUniqueAttribute
public MyValidateIsUniqueAttribute()
validator = Local.Data["IsUnitTest"] ? new
AlwaysReturnsNoErrorsValidator() : new IsUniqueValidator();
On Sep 9, 8:35 pm, James Thigpen <[EMAIL PROTECTED]> wrote:
> Hello all,
>
> I want to use the ValidateIsUnique attribute, but that means when
> testing my models I have to have bring up the entire database and init
> activerecord etc. even when I'm not testing my persistence layer
> which is slow and undesirable. I'm using ActiveRecordMediator based
> repositories.
>
> Is there any way around this? Perhaps this is just an indicator that
> "ValidateIsUnique" maybe doesn't belong in my domain models? It's a
> database concern I guess, but it's terribly convenient to be able to
> have it there and get the error message when I'm doing form
> submission.
>
> Any suggestions greatly appreciated.
>
> Thanks,
>
> -jt
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Castle Project Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/castle-project-users?hl=en
-~----------~----~----~----~------~----~------~--~---