ssteenkiste / nettiers

Automatically exported from code.google.com/p/nettiers
1 stars 0 forks source link

Step_30_TestFindByQuery doesn't build a good test. #317

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
I have some relation tables in my application that basically only have 2-3 
fields in them.  All of the fields are either foreign keys, or primary keys, or 
both.  (I have attached a script with a simple schema.  This was created with 
SQL Server 2008.)  The Step_30_TestFindByQuery unit test that is created for 
the TMS_REL_CLIENT_ADDRESS table doesn't work as the template is only including 
columns that aren't foreign keys or primary keys.  And when all of the columns 
are of those types then the test runs with no predicate and will fail if your 
database has test data in it.

What is the expected output? What do you see instead?
I think that the current behavior undermines the purpose of the test.  Really 
it should not matter that the query checks all of the columns, including 
primary keys and foreign keys.  Realistically, it would be a better test 
because all of the fields would have to equal the criteria, not just the non 
key fields.

What version of .netTiers and CodeSmith are you using?
I am using version r833.

Please provide any additional information below.
Here is the change I made to the template file 
EntityRepositoryTest.generated.cst locally.  It is possible that I am missing 
something, but my tests now all complete successfully.  (I have approx. 40 
tables in this application currently.)

Before:
<% if ( !cols[x].IsForeignKeyMember && !IsIdentityColumn(cols[x]) && 
!IsComputed(cols[x]) && IsColumnFindable(cols[x]) )
{ %>

After:
<% if ( !IsComputed(cols[x]) && IsColumnFindable(cols[x]) )
{ %>

I also tried a couple of other things.  Namely, I added a counter and if no 
predicates were added to the query then I just added all of the columns, but 
that caused a problem when there was 1 non-key field (perhaps indicating 
IS_PRIMARY, or something of the sort.

Original issue reported on code.google.com by emax...@gmail.com on 15 Jun 2010 at 3:38

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by bniemyjski on 21 Sep 2010 at 12:31