문제

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.

도움이 되었습니까?

해결책

So changing from .Find to...

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

Solves it.

다른 팁

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

return Conference.Find(c => c.Approved == true).ToList(); 
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top