Matt Roberts
Matt Roberts

Reputation: 26917

Subsonic 3.0 TestRepository "Find" not working

Using Subsonic 3, I have a simple class called "ConferenceRepository" that has a method that returns a bunch of conferences based on their status. I am testing this using SubSonic's built in support for testing. My setup of the repo looks like this:

// 2 Approved, 4 pending, 3 rejected
var data = new List<Conference>
               {
                   new Conference {Approved = true, Rejected = false},
                   new Conference {Approved = true, Rejected = false},
                   new Conference {Approved = false, Rejected = false},
                   new Conference {Approved = false, Rejected = false},
                   new Conference {Approved = false, Rejected = false},
                   new Conference {Approved = false, Rejected = false},
                   new Conference {Approved = false, Rejected = true},
                   new Conference {Approved = false, Rejected = true},
                   new Conference {Approved = false, Rejected = true}
               };

Conference.ResetTestRepo();
Conference.Setup(data);

And then my Repo class eventually executes this line, using Find():

return Conference.Find(c => c.Approved).ToList(); 

Trouble is, this always returns all the records (9). I've tried different find criteria, to no avail.

Anyone know what the issue is? I've tried fixing equality comparison in the tt templates as described here: Fixes for problems with SubSonic 3's TestRepository but that doesn't help.

Upvotes: 0

Views: 100

Answers (2)

Matt Roberts
Matt Roberts

Reputation: 26917

So changing from .Find to...

return Conference.All().Where(c => c.Approved == true).ToList(); 

Solves it.

Upvotes: 1

J&#252;rgen Steinblock
J&#252;rgen Steinblock

Reputation: 31743

Shouldn't make any difference, but did you tried:

return Conference.Find(c => c.Approved == true).ToList(); 

Upvotes: 0

Related Questions