Hi Patrick, first of all, thanks for your reply.
On Thu, May 5, 2011 at 1:44 PM, Patrick Steele <[email protected]> wrote: > You want to make sure that your FooProvider will not return any of the > blacklisted items. Uhm... almost. :-) > I also > assume you've got some kind of a repository layer that you can stub > out so you're not hitting the DB during your unit tests. Of course. The repository layer is represented from the IDataContext interface of which I wrote previously in the thread. > // arrange > IRepository repository = MockRepository.GenerateStub<IRepository>(); > var fooProvider = new FooProvider(repository); > fooProvider.BlackList = new [] { "A", "E", "I" }; > repository.Stub(r => r.GetNext10Items()).Return(new [] { "A", "B", > "C", "D", "E"}); > > // act > var result = fooProvider.GetItems(); // internally calls > repository.GetNext10Items() > > // assert > Assert.AreEqual(3, result.Count); > Assert.IsTrue(result.Contains("B"); > Assert.IsTrue(result.Contains("C"); > Assert.IsTrue(result.Contains("D"); Ok, there something I don't like: it seems like I'm testing the List<T>.Contains() method. In fact using this approach (which is quite black-box oriented) I cannot verify that at a certain point and under some conditions the List<T>.Contains() method is called, even if I can verify the effect of that call. Now, as I'm quite new to advanced unit-testing I ask: is it just a problem of mine? ;-) Thanks, Giulio -- -- You received this message because you are subscribed to the Google Groups "Rhino.Mocks" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rhinomocks?hl=en.
