tag:blogger.com,1999:blog-2441850399540300710.post1516137416565422546..comments2024-02-17T03:47:06.818-08:00Comments on CraigBlog: Defaulted Pluggable Configuration ProvidersCraig Anderahttp://www.blogger.com/profile/17084199593129216563noreply@blogger.comBlogger4125tag:blogger.com,1999:blog-2441850399540300710.post-35353295492653173782005-02-17T08:55:00.000-08:002005-02-17T08:55:00.000-08:00OK, that looks moderately useful. Not *much* less ...OK, that looks moderately useful. Not *much* less code, but a bit. <br /><br><br /><br>I'd probably stay away from this for anything more complicated than this simple example, though - to me it seems less readable, and since it's only slightly less verbose, the tradeoff doesn't seem worth it for more substantial situations.<br /><br><br /><br>But I'm willing to admit I might be wrong. :)Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-2441850399540300710.post-82860246529787740072005-02-17T08:20:00.000-08:002005-02-17T08:20:00.000-08:00That makes sense then! :) This cuts down the code...That makes sense then! :) This cuts down the code for test fixtures which always helps new comers get over the resistance to TDD I think. This is the pseudo-code:<br /><br><br /><br>// NMock will generate a type that <br /><br>// implements the interface<br /><br>DynamicMock mockConfig = <br /><br> new DynamicMock( typeof(IGetConfigData));<br /><br><br /><br>// pass in a sample of config data - if this<br /><br>// method isn't called the test will fail<br /><br>mockConfig.ExpectAndReturn("GetConfigData", <br /><br> new ConfigData()); <br /><br>return (IGetConfigData)mockConfig.MockInstance;<br /><br>Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-2441850399540300710.post-22080722606739832562005-02-17T08:14:00.000-08:002005-02-17T08:14:00.000-08:00Well, the main reason is, I'm not familiar wit...Well, the main reason is, I'm not familiar with it. :) <br /><br><br /><br>But isn't it a feature of NUnit 2.2? I'm still using 2.1.4 in most places.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-2441850399540300710.post-84054401726433561342005-02-17T08:12:00.000-08:002005-02-17T08:12:00.000-08:00Craig, one question is why do you explicitly imple...Craig, one question is why do you explicitly implement the mock version? Why not use the NUnit's built in mock objects support and set use DynamicMock.ExpectAndReturn() if verifying how consumers of IGetConfigData interact with the interface? Still, the pluggable aspect of interface dependencies is worth mentioning to readers.Anonymousnoreply@blogger.com