Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
ValidateIsUnique vs. Testing
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
James Thigpen  
View profile  
 More options Sep 9 2008, 8:35 pm
From: James Thigpen <James.R.Thig...@gmail.com>
Date: Tue, 9 Sep 2008 17:35:10 -0700 (PDT)
Local: Tues, Sep 9 2008 8:35 pm
Subject: ValidateIsUnique vs. Testing
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 must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Eric Hauser  
View profile  
 More options Sep 10 2008, 1:16 pm
From: Eric Hauser <ewhau...@gmail.com>
Date: Wed, 10 Sep 2008 10:16:09 -0700 (PDT)
Local: Wed, Sep 10 2008 1:16 pm
Subject: Re: ValidateIsUnique vs. Testing
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 <James.R.Thig...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Victor Kornov  
View profile  
 More options Sep 10 2008, 1:33 pm
From: "Victor Kornov" <wee...@gmail.com>
Date: Wed, 10 Sep 2008 21:33:37 +0400
Local: Wed, Sep 10 2008 1:33 pm
Subject: Re: ValidateIsUnique vs. Testing

Confirmed, that works. I've moved from ValidateIsUniqueAttribute later
anyways.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
James Thigpen  
View profile  
 More options Sep 11 2008, 9:57 am
From: James Thigpen <James.R.Thig...@gmail.com>
Date: Thu, 11 Sep 2008 06:57:59 -0700 (PDT)
Local: Thurs, Sep 11 2008 9:57 am
Subject: Re: ValidateIsUnique vs. Testing
This worked great. I ended up putting a static property on my custom
ValidateIsUniqueSometimes attribute to enable or disable it.

Thanks so much!

-jt

On Sep 10, 10:33 am, "Victor Kornov" <wee...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »