<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>AboutCode.net - boo</title>
    <link>http://www.aboutcode.net/</link>
    <description>Thoughts on Software by Andrew Davey</description>
    <language>en-us</language>
    <copyright>Andrew Davey</copyright>
    <lastBuildDate>Tue, 14 Aug 2007 13:02:43 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 2.2.8279.16125</generator>
    <managingEditor>andrew@equin.co.uk</managingEditor>
    <webMaster>andrew@equin.co.uk</webMaster>
    <item>
      <trackback:ping>http://www.aboutcode.net/Trackback.aspx?guid=992199d9-96aa-42ea-a904-86fef64459f0</trackback:ping>
      <pingback:server>http://www.aboutcode.net/pingback.aspx</pingback:server>
      <pingback:target>http://www.aboutcode.net/PermaLink,guid,992199d9-96aa-42ea-a904-86fef64459f0.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.aboutcode.net/CommentView,guid,992199d9-96aa-42ea-a904-86fef64459f0.aspx</wfw:comment>
      <wfw:commentRss>http://www.aboutcode.net/SyndicationService.asmx/GetEntryCommentsRss?guid=992199d9-96aa-42ea-a904-86fef64459f0</wfw:commentRss>
      <title>A (somewhat) new approach to application development</title>
      <guid isPermaLink="false">http://www.aboutcode.net/PermaLink,guid,992199d9-96aa-42ea-a904-86fef64459f0.aspx</guid>
      <link>http://www.aboutcode.net/2007/08/14/ASomewhatNewApproachToApplicationDevelopment.aspx</link>
      <pubDate>Tue, 14 Aug 2007 13:02:43 GMT</pubDate>
      <description>&lt;p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;
&lt;font color=#000000&gt;I am excited about Silverlight 1.1 – very excited! Whilst all
the graphics and animations will be a wonder for creating great user experiences,
I eagerly awaiting the chance to run managed code in the browser.&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;
&lt;font color=#000000&gt;In my mind, and partially in code, I have already begun to formulate
a new way to design applications. Of course, by &lt;i style="mso-bidi-font-style: normal"&gt;new&lt;/i&gt; I
really mean stealing a bunch of existing good ideas and gluing them together!&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;
&lt;font color=#000000&gt;The first key idea is putting the users first – always. These
auto-magic, drag-n-drop data binding tools are great for quick and dirty CRUD applications,
but I am yet to see one produce an application that has great usability. We need to
start by putting ourselves in the user’s position and thinking about why they are
using our software in the first place. It is all about finding the simplest, cleanest,
more beautiful way to enable the user to get their job done. Slapping another data
grid on a page probably is the worst approach!&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;
&lt;font color=#000000&gt;I am a new convert to the Model-View-Presenter way of writing
client applications. Although, I think, the order of coding should be Presenter-View-Model
(it does not have quite the same ring to it however). In addition, by View I mean
the view implementation, not the UI design. I always sketch the view design on paper/white
board first. I suppose using a tool like Microsoft Expression Blend would be OK as
long as you are not precious about the XAML it creates. I am never afraid to throw
out code and start afresh, so why should UI mark-up be any different? Use whatever
tools you find easiest to knock up UI prototypes and shove them under the user’s nose.
The key here is to know roughly what buttons, textboxes, etc, the UI will contain
(we can leave all the fancy colouring in to some guy in a turtle neck). Once this
is the case, we can begin the most important part of the coding: The User Interaction
Logic (UIL).&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;
&lt;font color=#000000&gt;The UIL is the Presenter. The UIL says stuff like when the user
clicks this button, read this data from the UI, tell the underlying model to do something
and then tell the view to update. Whilst for some applications this level of control
may seem like overkill, I argue that having to slow down sometimes is OK. This approach
means you have to think about what the user will be doing in your application.&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;
&lt;font color=#000000&gt;The best way to develop this code is by being test-driven. Create
unit tests that describe the behaviour of the Presenter in terms of how it interacts
with View and Model object-oriented interfaces. Each user story then becomes testable.&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;
&lt;font color=#000000&gt;Key tools I plan to use here are:&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;
&lt;font color=#000000&gt;Rhino Mocks – to create mock objects of Views and Models&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;
&lt;font color=#000000&gt;Boo + my Rhino Mocks DSL – to make the unit tests easy to read
and write&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;
&lt;font color=#000000&gt;SharpDevelop – because Boo is not readily usable in Visual Studio
yet&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;
&lt;font color=#000000&gt;Visual Studio 2008 – to write the implementation of the Presenter
in C#&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;
&lt;font color=#000000&gt;As awesome as the language Boo is, I just cannot stand SharpDevelop
for more than simple projects like the unit tests. Refactoring, intellisense and code-completion
are just way to well done in Visual Studio to ignore it. I have enough memory and
screen space to run VS and SD side-by-side.&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;
&lt;font color=#000000&gt;As the Presenter is written, the interfaces for the View and Model
are being fleshed out. The refactoring tool adding the methods automatically to the
interfaces usually does this.&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;
&lt;font color=#000000&gt;The choice now is whether to develop the Model or the View next.
The View is a very dumb object that simply maps data to and from the UI and raises
events when the user does stuff (clicks, key presses, etc). Since Silverlight does
not have data binding yet, this may lead to somewhat tedious code. Bear in mind also
that the Presenter is meant to be doing tasks such as converting strings into numbers
and back. However, I reckon a tool can generate most of the standard mapping code.&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;
&lt;font color=#000000&gt;The declarative nature of XAML means it should be easy to add
attributes to button elements that describe the event they should raise when clicked.
A tool could scan this data and write the code for me.&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;
&lt;font color=#000000&gt;If data binding was ever added to Silverlight, I would consider
creating pure “data” objects that the Presenter tells the View to bind too. No logic
would be contained within the data objects.&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;
&lt;font color=#000000&gt;The Model is where things become more interesting from a software
architecture point of view. Silverlight runs in the client’s web browser. So the Presenter
is running client-side, as is the Model on which is depends. The Model is maintaining
state about the client application. For example, which check boxes are checked, which
customer is selected? However, the Model also will need to communicate with a database
running back on the server to read and write data.&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;
&lt;font color=#000000&gt;To solve this problem, I plan to use my tier splitting C# macro.
I will write the Model class as one coherent class. By coherent I mean all the data
is there and all the logic regarding the data is there. I do not believe manually
splitting the class and messing about with proxies and web services makes any business
sense. I am not developing some kind of SOA application that is to be called by numerous
different clients. I am trying to get my Model to save its valuable data on the database
that is only accessible from the web server from whence it came. This is a reasonable
tight coupling between the client and server versions of the Model. The coupling is
so tight; I argue that I do not even want to see it!&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;
&lt;font color=#000000&gt;In the case where the data does come from a remote web service,
we &lt;i style="mso-bidi-font-style: normal"&gt;still&lt;/i&gt; have to return to the application’s
home server since Silverlight disallows cross-domain calls. It makes sense to put
any database calls/remote web services calls into the Model. The Model knows what
data it needs, so why bother moving that knowledge outside of the class only to marshal
all the data back in again.&lt;span style="FONT-SIZE: 14pt; mso-bidi-font-size: 12.0pt"&gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;
&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;
&lt;font color=#000000&gt;With LINQ being available we do not even have to pollute the Model
with database specific SQL.&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;
&lt;font color=#000000&gt;The tier splitting macro will handle generating all the WCF services
and proxies. I just have to decorate the Model’s remote methods with [RunAtServer].&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;
&lt;font color=#000000&gt;Thorough unit testing of the Model is required. It should be possible
to create a mock D-LINQ implementation. I can then make assertions about how the Model
interacts with the data layer.&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;
&lt;font color=#000000&gt;In summary, I want to have a Silverlight UI that is but a marionette
to a Presenter running client-side. This presenter has complete unit testing to describe
the different user interactions. The Presenter uses a Model object to store all data.
This Model exists on both the client and server side. However, the split implementation
is effectively invisible to the developer.&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;
&lt;font color=#000000&gt;The application of adequate tooling (both 3&lt;sup&gt;rd&lt;/sup&gt; party
and custom made) will make this an excellent way to approach writing applications.
As Silverlight 1.1 becomes more complete, I will continue to expand this topic.&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;
&lt;font color=#000000&gt;The result should be a happier developer and, more importantly,
a happier user.&lt;/font&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.aboutcode.net/aggbug.ashx?id=992199d9-96aa-42ea-a904-86fef64459f0" /&gt;</description>
      <comments>http://www.aboutcode.net/CommentView,guid,992199d9-96aa-42ea-a904-86fef64459f0.aspx</comments>
      <category>.net</category>
      <category>boo</category>
      <category>c#</category>
      <category>dsl</category>
      <category>programming</category>
      <category>rhino_mocks</category>
      <category>ria</category>
      <category>silverlight</category>
      <category>tier_split</category>
    </item>
    <item>
      <trackback:ping>http://www.aboutcode.net/Trackback.aspx?guid=22f4a0bf-c4cc-4241-9e44-ead51b136b1a</trackback:ping>
      <pingback:server>http://www.aboutcode.net/pingback.aspx</pingback:server>
      <pingback:target>http://www.aboutcode.net/PermaLink,guid,22f4a0bf-c4cc-4241-9e44-ead51b136b1a.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.aboutcode.net/CommentView,guid,22f4a0bf-c4cc-4241-9e44-ead51b136b1a.aspx</wfw:comment>
      <wfw:commentRss>http://www.aboutcode.net/SyndicationService.asmx/GetEntryCommentsRss?guid=22f4a0bf-c4cc-4241-9e44-ead51b136b1a</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I have attached the Boo code containing the Rhino Mocks DSL I'm currently working
on. This is very much a work in progress release, just to get it out there. Please
have a play and tell me what you think. Happy Mocking!
</p>
        <p>
          <a href="http://www.aboutcode.net/content/binary/Dsl.boo">Dsl.boo (3.4 KB)</a>
        </p>
        <p>
To use the DSL, add the following in your code to import the static methods into scope.
</p>
        <p>
          <font face="Courier New">import Rhino.Mocks.Dsl</font>
        </p>
        <img width="0" height="0" src="http://www.aboutcode.net/aggbug.ashx?id=22f4a0bf-c4cc-4241-9e44-ead51b136b1a" />
      </body>
      <title>Code for the Rhino Mock DSL</title>
      <guid isPermaLink="false">http://www.aboutcode.net/PermaLink,guid,22f4a0bf-c4cc-4241-9e44-ead51b136b1a.aspx</guid>
      <link>http://www.aboutcode.net/2007/07/06/CodeForTheRhinoMockDSL.aspx</link>
      <pubDate>Fri, 06 Jul 2007 12:19:48 GMT</pubDate>
      <description>&lt;p&gt;
I have attached the Boo code containing the Rhino Mocks DSL I'm currently working
on. This is very much a work in progress release, just to get it out there. Please
have a play and tell me what you think. Happy Mocking!
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.aboutcode.net/content/binary/Dsl.boo"&gt;Dsl.boo (3.4 KB)&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
To use the DSL, add the following in your code to import the static methods into scope.
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;import Rhino.Mocks.Dsl&lt;/font&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.aboutcode.net/aggbug.ashx?id=22f4a0bf-c4cc-4241-9e44-ead51b136b1a" /&gt;</description>
      <comments>http://www.aboutcode.net/CommentView,guid,22f4a0bf-c4cc-4241-9e44-ead51b136b1a.aspx</comments>
      <category>.net</category>
      <category>boo</category>
      <category>dsl</category>
      <category>mock_objects</category>
      <category>programming</category>
      <category>rhino_mocks</category>
    </item>
    <item>
      <trackback:ping>http://www.aboutcode.net/Trackback.aspx?guid=9126ea1f-4fcd-438b-a8f1-8f040fdc5b53</trackback:ping>
      <pingback:server>http://www.aboutcode.net/pingback.aspx</pingback:server>
      <pingback:target>http://www.aboutcode.net/PermaLink,guid,9126ea1f-4fcd-438b-a8f1-8f040fdc5b53.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.aboutcode.net/CommentView,guid,9126ea1f-4fcd-438b-a8f1-8f040fdc5b53.aspx</wfw:comment>
      <wfw:commentRss>http://www.aboutcode.net/SyndicationService.asmx/GetEntryCommentsRss?guid=9126ea1f-4fcd-438b-a8f1-8f040fdc5b53</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I thought some more about the syntax of my Rhino Mock DSL. It can feel unnatural putting
all the mock expectation code before the call to the object being tested. I came up
with this working prototype instead:
</p>
        <p>
          <font face="Courier New">[Test]<br />
def Get_data_objects_for_nonexistent_company_throws():<br />
    with_mocks:<br />
        database = mocks.CreateMock[of IDatabase]()<br />
        userProvider = StubUserProvider("andrew",
"bad corp")<br />
        userProvider.MakeCurrent()<br /><br />
        execute:<br />
            uds = UserDataService(database,
userProvider)<br />
            expect_throw FaultException[of
GetDataObjectsFault]:<br />
               
uds.GetDataObjects()<br />
            assert thrown_exception.Detail.Type.Equals(GetDataObjectsFaultType.InvalidCompany)<br /><br />
        assuming:<br />
            database.GetUserID("andrew",
"bad corp")<br />
            returned 1<br />
        assuming:<br />
            database.GetCompanyID("bad
corp")<br />
            returned 0 # returning
0 from database implies nonexistent company.</font>
        </p>
        <p>
          <font face="ver">The <font face="Courier New">with_mocks</font> method sets up the
mock repository and a Store object. The <font face="Courier New">execute</font> and <font face="Courier New">assumption</font> methods
then put their blocks into the Store. At the end of <font face="Courier New">with_mocks</font> I
iterate through assumptions calling each to set up the Rhino Mock expectations. Following
that is: <font face="Courier New">mocks.ReplayAll()</font>, call to the "execute"
block, then <font face="Courier New">mocks.VerifyAll()</font>.</font>
        </p>
        <p>
The other clever bit in there is the <font face="Courier New">expect_throw</font> method.
This runs the block inside a <font face="Courier New">try...except</font> and fails
if no exception (or wrong exception type) is thrown. It puts the exception object
into field that is readable using <font face="Courier New">thrown_exception</font>.
This means we can then test assertions about the exception contents. I had to cheat
a bit and declare <font face="Courier New">thrown_exception</font> as "duck" in Boo
i.e. it is late bound. This is so we can access members on the actual object despite
not really knowing about it at compile time.
</p>
        <p>
I like the readability now. The outline is:
</p>
        <ul>
          <li>
Initialize mocks and data objects</li>
          <li>
Call the object being tested</li>
          <li>
Assert about the result</li>
          <li>
State the assumptions about how dependencies are used</li>
        </ul>
        <p>
The key bit, I feel, is that the call to the object being tested is not buried down
at the bottom of the method.
</p>
        <p>
How does everyone else feel about this modified approach?
</p>
        <img width="0" height="0" src="http://www.aboutcode.net/aggbug.ashx?id=9126ea1f-4fcd-438b-a8f1-8f040fdc5b53" />
      </body>
      <title>Better Syntax for Mocking</title>
      <guid isPermaLink="false">http://www.aboutcode.net/PermaLink,guid,9126ea1f-4fcd-438b-a8f1-8f040fdc5b53.aspx</guid>
      <link>http://www.aboutcode.net/2007/07/04/BetterSyntaxForMocking.aspx</link>
      <pubDate>Wed, 04 Jul 2007 10:41:55 GMT</pubDate>
      <description>&lt;p&gt;
I thought some more about the syntax of my Rhino Mock DSL. It can feel unnatural putting
all the mock expectation code before the call to the object being tested. I came up
with this working prototype instead:
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;[Test]&lt;br&gt;
def Get_data_objects_for_nonexistent_company_throws():&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; with_mocks:&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; database = mocks.CreateMock[of IDatabase]()&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; userProvider = StubUserProvider("andrew",
"bad corp")&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; userProvider.MakeCurrent()&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; execute:&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; uds = UserDataService(database,
userProvider)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; expect_throw FaultException[of
GetDataObjectsFault]:&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
uds.GetDataObjects()&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; assert thrown_exception.Detail.Type.Equals(GetDataObjectsFaultType.InvalidCompany)&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; assuming:&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; database.GetUserID("andrew",
"bad corp")&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; returned 1&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; assuming:&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; database.GetCompanyID("bad
corp")&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; returned 0 # returning
0 from database implies nonexistent company.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="ver"&gt;The &lt;font face="Courier New"&gt;with_mocks&lt;/font&gt; method sets up the
mock repository and a Store object. The &lt;font face="Courier New"&gt;execute&lt;/font&gt; and &lt;font face="Courier New"&gt;assumption&lt;/font&gt; methods
then put their blocks into the Store. At the end of &lt;font face="Courier New"&gt;with_mocks&lt;/font&gt; I
iterate through assumptions calling each to set up the Rhino Mock expectations. Following
that is: &lt;font face="Courier New"&gt;mocks.ReplayAll()&lt;/font&gt;, call to the "execute"
block, then &lt;font face="Courier New"&gt;mocks.VerifyAll()&lt;/font&gt;.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
The other clever bit in there is the &lt;font face="Courier New"&gt;expect_throw&lt;/font&gt; method.
This runs the block inside a &lt;font face="Courier New"&gt;try...except&lt;/font&gt; and fails
if no exception (or wrong exception type) is thrown. It puts the exception object
into field that is readable using &lt;font face="Courier New"&gt;thrown_exception&lt;/font&gt;.
This means we can then test assertions about the exception contents. I had to cheat
a bit and declare &lt;font face="Courier New"&gt;thrown_exception&lt;/font&gt; as "duck" in Boo
i.e. it is late bound. This is so we can access members on the actual object despite
not really knowing about it at compile time.
&lt;/p&gt;
&lt;p&gt;
I like the readability now. The outline is:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
Initialize mocks and data objects&lt;/li&gt;
&lt;li&gt;
Call the object being tested&lt;/li&gt;
&lt;li&gt;
Assert about the result&lt;/li&gt;
&lt;li&gt;
State the assumptions about how dependencies are used&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
The key bit, I feel, is that the call to the object being tested is not buried down
at the bottom of the method.
&lt;/p&gt;
&lt;p&gt;
How does everyone else feel about this modified approach?
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.aboutcode.net/aggbug.ashx?id=9126ea1f-4fcd-438b-a8f1-8f040fdc5b53" /&gt;</description>
      <comments>http://www.aboutcode.net/CommentView,guid,9126ea1f-4fcd-438b-a8f1-8f040fdc5b53.aspx</comments>
      <category>.net</category>
      <category>boo</category>
      <category>dsl</category>
      <category>mock_objects</category>
      <category>programming</category>
      <category>rhino_mocks</category>
    </item>
    <item>
      <trackback:ping>http://www.aboutcode.net/Trackback.aspx?guid=40883495-3f6a-4bcc-885b-8a6b132bc53a</trackback:ping>
      <pingback:server>http://www.aboutcode.net/pingback.aspx</pingback:server>
      <pingback:target>http://www.aboutcode.net/PermaLink,guid,40883495-3f6a-4bcc-885b-8a6b132bc53a.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.aboutcode.net/CommentView,guid,40883495-3f6a-4bcc-885b-8a6b132bc53a.aspx</wfw:comment>
      <wfw:commentRss>http://www.aboutcode.net/SyndicationService.asmx/GetEntryCommentsRss?guid=40883495-3f6a-4bcc-885b-8a6b132bc53a</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I recently learnt that Boo now supports a <a href="http://jira.codehaus.org/browse/BOO-835">DSL-friendly
syntax</a>. A while back I created (and almost finished!) a set of syntactic macros
in Boo to make using Rhino Mocks much more natural. Creating macros can be hard work
though and gets pretty hacky in places.
</p>
        <p>
The new DSL-friendly syntax in Boo means I can achieve 80% of the same easy-reading
code, but using only methods and blocks!
</p>
        <p>
In about 10 minutes I whipped up this:
</p>
        <p>
          <font face="Courier New">namespace ConsoleDemo </font>
        </p>
        <p>
          <font face="Courier New">import System<br />
import Rhino.Mocks<br />
import Rhino.Mocks.BooDsl.MockDsl </font>
        </p>
        <p>
          <font face="Courier New">interface IModel:<br />
    def CalculateScore(input as int) as int<br />
interface IView:<br />
    def DisplayScore(score as int)<br />
interface IPresenter:<br />
    def Init()<br /><br />
class Presenter(IPresenter):<br />
    _model as IModel<br />
    _view as IView<br />
    def constructor(model as IModel, view as IView):<br />
        _model = model<br />
        _view = view<br />
    def Init():<br />
        score = _model.CalculateScore(0)<br />
        _view.DisplayScore(score)<br /><br />
def Test_presenter_init():<br />
    with_mocks:<br />
        // Create mocks of the dependencies<br />
        model = Mocks.CreateMock of IModel()<br />
        view = Mocks.CreateMock of IView()<br />
        // Create the object we are testing<br />
        presenter = Presenter(model, view)<br />
        // Record what we expect the presenter
to 
<br />
        // do with its dependencies.<br />
        record:<br />
            expect:<br />
               
model.CalculateScore(0)<br />
               
// Set the return value for the 
<br />
               
// previous mock call.<br />
               
mock_return 42<br />
            expect:<br />
               
view.DisplayScore(42)<br />
        // Now tell the presenter to do its stuff, 
<br />
        // so we can verify it behaves correctly.<br />
        verify:<br />
            presenter.Init()<br />
print "testing..."<br />
Test_presenter_init()<br />
print "all good!"<br />
print "Press any key to continue . . . "<br />
Console.ReadKey(true)</font>
        </p>
        <p>
The import of "Rhino.Mocks.BooDsl.MockDsl" brings some new methods into scope. with_mocks
initializes a MockRepository. "Mocks" is actually a property referencing that repository,
so we can call CreateMock, etc, on it. The record and verify methods make use of the
Mocks.Record() and Mocks.Playback() methods. I prefer using "verify" to "playback".
The "expect" method runs the code in its block, usually that invokes some mock method.
It then calls "LastCall.Repeat.Once()" to set up the expectation. The "mock_return"
method calls "LastCall.Return(value)" to set up the return value for the last mock
call.
</p>
        <p>
This is all a bit messy for now I know. I have just being throwing code down into
this prototype to get a feel for what is possible. I reckon this could be really useful
for people using Rhino Mocks.
</p>
        <p>
If you like what you've seen or have any ideas let me know.
</p>
        <p>
The DSL methods are as follows:<br />
I am aware of more than one glaring danger in the code(!) but it does show what can
be done.
</p>
        <p>
          <font face="Courier New">namespace Rhino.Mocks.BooDsl </font>
        </p>
        <p>
          <font face="Courier New">import System<br />
import Rhino.Mocks </font>
        </p>
        <p>
          <font face="Courier New">callable Block()<br /><br />
static class MockDsl: </font>
        </p>
        <p>
          <font face="Courier New">    private static _instance as MockDslImpl<br />
    static def with_mocks(b as Block):<br />
        _instance = MockDslImpl()<br />
        b()<br />
        _instance = null<br />
    static def record(b as Block):<br />
        assert _instance != null<br />
        _instance.Record(b)<br />
    static def verify(b as Block):<br />
        assert _instance != null<br />
        _instance.Verify(b)<br />
    static def expect(b as Block):<br />
        assert _instance != null<br />
        _instance.Expect(b)<br />
    static def mock_return(value as object):<br />
        assert _instance != null<br />
        _instance.MockReturn(value)<br />
    static Mocks as MockRepository:<br />
        get:<br />
            assert _instance
!= null<br />
            return _instance.Mocks </font>
        </p>
        <p>
          <font face="Courier New">    private class MockDslImpl:<br />
        mocks as MockRepository<br />
        def constructor():<br />
            mocks = MockRepository()<br />
        public Mocks as MockRepository:<br />
            get:<br />
               
return mocks<br />
        public def Record(b as Block):<br />
            using mocks.Record():<br />
               
b()<br />
        public def Verify(b as Block):<br />
            using mocks.Playback():<br />
               
b()<br />
        public def Expect(b as Block):<br />
            b()<br />
            LastCall.Repeat.Once()<br />
        public def MockReturn(value as object):<br />
            LastCall.Return(value)</font>
        </p>
        <img width="0" height="0" src="http://www.aboutcode.net/aggbug.ashx?id=40883495-3f6a-4bcc-885b-8a6b132bc53a" />
      </body>
      <title>Rhino Mocks DSL in Boo</title>
      <guid isPermaLink="false">http://www.aboutcode.net/PermaLink,guid,40883495-3f6a-4bcc-885b-8a6b132bc53a.aspx</guid>
      <link>http://www.aboutcode.net/2007/07/02/RhinoMocksDSLInBoo.aspx</link>
      <pubDate>Mon, 02 Jul 2007 23:03:52 GMT</pubDate>
      <description>&lt;p&gt;
I recently learnt that Boo now supports a &lt;a href="http://jira.codehaus.org/browse/BOO-835"&gt;DSL-friendly
syntax&lt;/a&gt;. A while back I created (and almost finished!) a set of syntactic macros
in Boo to make using Rhino Mocks much more natural. Creating macros can be hard work
though and gets pretty hacky in places.
&lt;/p&gt;
&lt;p&gt;
The new DSL-friendly syntax in Boo means I can achieve 80% of the same easy-reading
code, but using only&amp;nbsp;methods and blocks!
&lt;/p&gt;
&lt;p&gt;
In about 10 minutes I whipped up this:
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;namespace ConsoleDemo &lt;/font&gt; 
&lt;p&gt;
&lt;font face="Courier New"&gt;import System&lt;br&gt;
import Rhino.Mocks&lt;br&gt;
import Rhino.Mocks.BooDsl.MockDsl &lt;/font&gt; 
&lt;p&gt;
&lt;font face="Courier New"&gt;interface IModel:&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; def CalculateScore(input as int) as int&lt;br&gt;
interface IView:&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; def DisplayScore(score as int)&lt;br&gt;
interface IPresenter:&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; def Init()&lt;br&gt;
&lt;br&gt;
class Presenter(IPresenter):&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; _model as IModel&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; _view as IView&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; def constructor(model as IModel, view as IView):&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _model = model&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _view = view&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; def Init():&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; score = _model.CalculateScore(0)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _view.DisplayScore(score)&lt;br&gt;
&lt;br&gt;
def Test_presenter_init():&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; with_mocks:&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Create mocks of the dependencies&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; model = Mocks.CreateMock of IModel()&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; view = Mocks.CreateMock of IView()&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Create the object we are testing&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; presenter = Presenter(model, view)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Record what we expect the presenter
to 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // do with its dependencies.&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; record:&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; expect:&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
model.CalculateScore(0)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
// Set the return value for the 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
// previous mock call.&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
mock_return 42&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; expect:&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
view.DisplayScore(42)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Now tell the presenter to do its stuff, 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // so we can verify it behaves correctly.&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; verify:&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; presenter.Init()&lt;br&gt;
print "testing..."&lt;br&gt;
Test_presenter_init()&lt;br&gt;
print "all good!"&lt;br&gt;
print "Press any key to continue . . . "&lt;br&gt;
Console.ReadKey(true)&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
The import of "Rhino.Mocks.BooDsl.MockDsl" brings some new methods into scope. with_mocks
initializes a MockRepository. "Mocks" is actually a property referencing that repository,
so we can call CreateMock, etc, on it. The record and verify methods make use of the
Mocks.Record() and Mocks.Playback() methods. I prefer using "verify" to "playback".
The "expect" method runs the code in its block, usually that invokes some mock method.
It then calls "LastCall.Repeat.Once()" to set up the expectation. The "mock_return"
method calls "LastCall.Return(value)" to set up the return value for the last mock
call.
&lt;/p&gt;
&lt;p&gt;
This is all a bit messy for now I know. I have just being throwing code down into
this prototype to get a feel for what is possible. I reckon this could be really useful
for people using Rhino Mocks.
&lt;/p&gt;
&lt;p&gt;
If you like what you've seen or have any ideas let me know.
&lt;/p&gt;
&lt;p&gt;
The DSL methods are as follows:&lt;br&gt;
I am aware of more than one glaring danger in the code(!) but it does show what can
be done.
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;namespace Rhino.Mocks.BooDsl &lt;/font&gt; 
&lt;p&gt;
&lt;font face="Courier New"&gt;import System&lt;br&gt;
import Rhino.Mocks &lt;/font&gt; 
&lt;p&gt;
&lt;font face="Courier New"&gt;callable Block()&lt;br&gt;
&lt;br&gt;
static class MockDsl: &lt;/font&gt; 
&lt;p&gt;
&lt;font face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; private static _instance as MockDslImpl&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; static def with_mocks(b as Block):&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _instance = MockDslImpl()&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; b()&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _instance = null&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; static def record(b as Block):&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; assert _instance != null&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _instance.Record(b)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; static def verify(b as Block):&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; assert _instance != null&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _instance.Verify(b)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; static def expect(b as Block):&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; assert _instance != null&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _instance.Expect(b)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; static def mock_return(value as object):&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; assert _instance != null&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _instance.MockReturn(value)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; static Mocks as MockRepository:&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; get:&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; assert _instance
!= null&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return _instance.Mocks &lt;/font&gt; 
&lt;p&gt;
&lt;font face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; private class MockDslImpl:&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mocks as MockRepository&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; def constructor():&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mocks = MockRepository()&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public Mocks as MockRepository:&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; get:&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
return mocks&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public def Record(b as Block):&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; using mocks.Record():&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
b()&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public def Verify(b as Block):&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; using mocks.Playback():&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
b()&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public def Expect(b as Block):&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; b()&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LastCall.Repeat.Once()&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public def MockReturn(value as object):&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LastCall.Return(value)&lt;/font&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.aboutcode.net/aggbug.ashx?id=40883495-3f6a-4bcc-885b-8a6b132bc53a" /&gt;</description>
      <comments>http://www.aboutcode.net/CommentView,guid,40883495-3f6a-4bcc-885b-8a6b132bc53a.aspx</comments>
      <category>.net</category>
      <category>boo</category>
      <category>dsl</category>
      <category>mock_objects</category>
      <category>programming</category>
      <category>rhino_mocks</category>
    </item>
  </channel>
</rss>