Question

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.

Was it helpful?

Solution

So changing from .Find to...

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

Solves it.

OTHER TIPS

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

return Conference.Find(c => c.Approved == true).ToList(); 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top