From: Steve F. <st...@m3...> - 2003-04-23 22:51:56
|
Alternatively, wrap File in a very shallow decorator that describes the behaviour you want in terms of your domain. Then provide mock and real implementations of that decorator. S. Jeff Martin wrote: > Probably the thing to do whould be to change the alt.java.io.File > interface to use a alt.java.io.FileFilter instead of java.io.FileFilter > which would use alt.java.io.File instead of java.io.File > > On Tue, 2003-04-22 at 22:49, Chris Sterritt wrote: > >>Hello, >> >> I'd like to be able to use MockObjects with a fairly complicated >>FileFilter-implementing class. In particular, I'd like to be able to set >>up a pseudo-directory tree (thanks to MockFile) and then verify that everything >>found is as it should be. However, I find that the class I want to test can't >>take a File as an argument to the method that searches the directory, because >>then I can't use a MockFile (similarly, the FileFilter-implementing >>class can't have an accept(MockFile mf) since that doesn't fulfil the >>interface). >> >> Is the right thing to have two versions of each method, or to implement >>some interface (MyFile) with a class that delegates to a real File in real >>code, and a MockFile in testing? >> >> Thanks, >> --chris sterritt >> >> >> >> >> >> >>------------------------------------------------------- >>This sf.net email is sponsored by:ThinkGeek >>Welcome to geek heaven. >>http://thinkgeek.com/sf >>_______________________________________________ >>Mockobjects-java-users mailing list >>Moc...@li... >>https://lists.sourceforge.net/lists/listinfo/mockobjects-java-users |