﻿<?xml version="1.0" encoding="utf-8"?><rss version="2.0"><channel><title>Ayende @ Rahien</title><link>http://ayende.com</link><description>Ayende @ Rahien</description><copyright>Copyright (C) Ayende Rahien  2004 - 2021 (c) 2026</copyright><ttl>60</ttl><item><title>Aaron Jensen commented on Advance Mocking with Rhino Mocks 3.5</title><description>Expect is an Assert. 
  
  
You should generally be asserting one thing in a test. 
  
  
If you are asserting that an interaction occurred, you should use Expect/Verify or AssertWasCalled.
  
  
If you testing state, you should *not* use these things, as then you are testing more than one thing in your test.
  
  
With regards to your finding Expect/Verify more natural, that's fine, but please don't call it AAA. That will only confuse the issue more than it already is.
  
  
I didn't mind Expect/Verify as much as I do now until I started writing context/spec style tests. At that point the AAA syntax became a necessity. Even before then though, I liked being able to look at the bottom of the test and see what should have happened... what I was testing.
  
</description><link>http://ayende.com/3398/advance-mocking-with-rhino-mocks-3-5#comment5</link><guid>http://ayende.com/3398/advance-mocking-with-rhino-mocks-3-5#comment5</guid><pubDate>Wed, 02 Jul 2008 07:05:35 GMT</pubDate></item><item><title>Ayende Rahien commented on Advance Mocking with Rhino Mocks 3.5</title><description>I am not following on the first statment.
  
  
For the second, I find it more natural to have an expectation before the interaction
</description><link>http://ayende.com/3398/advance-mocking-with-rhino-mocks-3-5#comment4</link><guid>http://ayende.com/3398/advance-mocking-with-rhino-mocks-3-5#comment4</guid><pubDate>Wed, 02 Jul 2008 06:50:09 GMT</pubDate></item><item><title>Aaron Jensen commented on Advance Mocking with Rhino Mocks 3.5</title><description>What? I would hope that unless you're testing the interaction you're not going to use Expect *OR* AssertWasCalled. 
  
  
How is it more natural to hide the assertion in the middle of the test? 
</description><link>http://ayende.com/3398/advance-mocking-with-rhino-mocks-3-5#comment3</link><guid>http://ayende.com/3398/advance-mocking-with-rhino-mocks-3-5#comment3</guid><pubDate>Wed, 02 Jul 2008 06:48:30 GMT</pubDate></item><item><title>Ayende Rahien commented on Advance Mocking with Rhino Mocks 3.5</title><description>This test test the _interaction_, as such, I find it much more natural to use Expect() and verify than to assert on that.
  
About ThenReturn(2), good idea, but this happen rarely enough that is is not a real concern of mine.
  
</description><link>http://ayende.com/3398/advance-mocking-with-rhino-mocks-3-5#comment2</link><guid>http://ayende.com/3398/advance-mocking-with-rhino-mocks-3-5#comment2</guid><pubDate>Wed, 02 Jul 2008 06:38:35 GMT</pubDate></item><item><title>Aaron Jensen commented on Advance Mocking with Rhino Mocks 3.5</title><description>You said you "use AAA for really nice syntax", but I don't see that in this test. The new extension methods you added are not AAA in my opinion unless you actually use AssertWasCalled. 
  
  
The whole point of our push for AAA in a mocking was to move away from setting up expectations in the middle of the test (like you did right before your replay) so that the test would be easier to follow.
  
  
Out of curiousity, why is your ReplayAll in the middle of your stubs? Would it be just as functional before the Run()?
  
  
I think having to use partial mocks is generally a smell. Most of the time you have to use them it's because you're violating SRP. This is a perfect example of that. I'd consider moving the Command creation into a factory.
  
  
The two ordered stubs after the ReplayAll are difficult to follow as well. How about a ThenReturn() method? 
  
foo.Stub(x=&gt;x.Bar()).Return(1).ThenReturn(2);
  
  
And no, I can't send a patch for this at this time :)
</description><link>http://ayende.com/3398/advance-mocking-with-rhino-mocks-3-5#comment1</link><guid>http://ayende.com/3398/advance-mocking-with-rhino-mocks-3-5#comment1</guid><pubDate>Wed, 02 Jul 2008 06:13:48 GMT</pubDate></item></channel></rss>