﻿<?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>Morten Lyhr commented on Rhino Mocks - Arrange, Act, Assert Syntax</title><description>I really like it alot.
  
  
I have written about BDD and AAA syntax here:
  
http://morten.lyhr.dk/2008/07/doing-bdd-with-rhino-mocks-aaa-syntax.html
  
  
They really mix very well.
</description><link>http://ayende.com/3318/rhino-mocks-arrange-act-assert-syntax#comment22</link><guid>http://ayende.com/3318/rhino-mocks-arrange-act-assert-syntax#comment22</guid><pubDate>Wed, 09 Jul 2008 06:54:28 GMT</pubDate></item><item><title>Ayende Rahien commented on Rhino Mocks - Arrange, Act, Assert Syntax</title><description>This should go to the mailing list
</description><link>http://ayende.com/3318/rhino-mocks-arrange-act-assert-syntax#comment21</link><guid>http://ayende.com/3318/rhino-mocks-arrange-act-assert-syntax#comment21</guid><pubDate>Wed, 25 Jun 2008 11:58:20 GMT</pubDate></item><item><title>Michael Reichenauer commented on Rhino Mocks - Arrange, Act, Assert Syntax</title><description>Hi!
  
Thanks for the new 3.5 beta syntax, it is really nice to use. 
  
However I have problems with mocking properties.  E.g.:
  
  
var httpClient = MockRepository.GenerateStub&lt;IHttpClient&gt;();
  
httpClient.BaseAddress = "blah";
  
httpClient.AssertWasCalled(x =&gt; x.BaseAddress = "blah");
  
  
Will cause a ExpectationViolationException on the third row. And also trying to mock properties properties with:
  
  
var httpClient = MockRepository.GenerateStub&lt;IHttpClient&gt;();
  
httpClient.Stub(m =&gt; m.BaseAddress).Return("mocked");
  
  
or:
  
  
httpClient.Stub(m =&gt; m.BaseAddress = null).Throw(new ArgumentException("error"));
  
  
fails on the Stub rows with a "InvalidOperationException : Invalid call, the last call has been used or no call has been made ..."
  
I would appreciate if someone could give me a hint.
  
  
</description><link>http://ayende.com/3318/rhino-mocks-arrange-act-assert-syntax#comment20</link><guid>http://ayende.com/3318/rhino-mocks-arrange-act-assert-syntax#comment20</guid><pubDate>Wed, 25 Jun 2008 07:51:02 GMT</pubDate></item><item><title>Ayende Rahien commented on Rhino Mocks - Arrange, Act, Assert Syntax</title><description>Yes, I'll try to do that.
</description><link>http://ayende.com/3318/rhino-mocks-arrange-act-assert-syntax#comment19</link><guid>http://ayende.com/3318/rhino-mocks-arrange-act-assert-syntax#comment19</guid><pubDate>Sat, 14 Jun 2008 01:46:23 GMT</pubDate></item><item><title>Jeremy Gray commented on Rhino Mocks - Arrange, Act, Assert Syntax</title><description>Yes, Ayende, I understand that the objects can be used without explicit record/replay, and have been using them that way quite successfully for most of the week. What I am curious about, though, is that the two methods are returning objects that don't seem to align with the previous terminology. The Mocks, for example, can be used as partial mocks, and more importantly have changed their strictness (they are acting much more loose than those returned from the classic StrictMock calls). I understand that you have yet to document this new syntax fully, but could you at least post a quick list of old call versus new call so that we can know what is what?
</description><link>http://ayende.com/3318/rhino-mocks-arrange-act-assert-syntax#comment18</link><guid>http://ayende.com/3318/rhino-mocks-arrange-act-assert-syntax#comment18</guid><pubDate>Sat, 14 Jun 2008 01:36:00 GMT</pubDate></item><item><title>Ayende Rahien commented on Rhino Mocks - Arrange, Act, Assert Syntax</title><description>The static methods are returning an object that can be used without record/replay. It is already in replay mode, which is needed to use the AAA syntax.
  
The missing partial is mainly an issue with not adding it, not a design decision.
  
I need to document that part fairly heavily
</description><link>http://ayende.com/3318/rhino-mocks-arrange-act-assert-syntax#comment17</link><guid>http://ayende.com/3318/rhino-mocks-arrange-act-assert-syntax#comment17</guid><pubDate>Sat, 14 Jun 2008 00:52:33 GMT</pubDate></item><item><title>Jeremy Gray commented on Rhino Mocks - Arrange, Act, Assert Syntax</title><description>Hehe. Nice copy/paste editing error on my part in that last comment. The actual question from me to Ayende should read:
  
  
Could you perhaps post back a quick reply comment showing what maps to what between the old MockRepository instance methods and the new static GenerateMock and GenerateStub methods?
</description><link>http://ayende.com/3318/rhino-mocks-arrange-act-assert-syntax#comment16</link><guid>http://ayende.com/3318/rhino-mocks-arrange-act-assert-syntax#comment16</guid><pubDate>Tue, 10 Jun 2008 17:22:13 GMT</pubDate></item><item><title>Jeremy Gray commented on Rhino Mocks - Arrange, Act, Assert Syntax</title><description>@Ayende - I know this is now an old-ish post but thought it the best place to pose this question:
  
  
I've been trying out the AAA syntax in the last day and noticed that GenerateMock doesn't appear to produce strict mocks, nor can it take constructor arguments. On the other hand, instances returned from GenerateStub seem capable of taking on expectations, which given the now-looser semantics of GenerateMock would tempt me to suggest that the only difference between GenerateMock and GenerateStub should be that instances returned by GenerateStub shouldn't be able to take on any expectations. I've also noticed that there is no Generate* equivalent to PartialMock, though both GenerateStub and GenerateMock seem happy to produce one (not that I can tell the difference in expected behaviour due to the other things noted earlier.)
  
  
Could you perhaps post back a quick reply comment showing what maps to what between the between old the MockRepository instance methods and the new static GenerateMock and Generatestub methods? Thanks in advance!
</description><link>http://ayende.com/3318/rhino-mocks-arrange-act-assert-syntax#comment15</link><guid>http://ayende.com/3318/rhino-mocks-arrange-act-assert-syntax#comment15</guid><pubDate>Tue, 10 Jun 2008 17:17:52 GMT</pubDate></item><item><title>Ayende Rahien commented on Rhino Mocks - Arrange, Act, Assert Syntax</title><description>Stub() doesn't set an expectation.
  
  
However, what I have found is that very often you want to do things like:
  
  
userRepository.Stub(x =&gt; x.GetUserById(5)).Return(new User { Id = 5, Name = "ayende" })
  
userRepository.Stub(x =&gt; x.GetUserById(6)).Return(new User { Id = 6, Name = "brad" })
  
  
This is just matching to parameters.
  
You can ask to not do that, but it turn out to be a rarer case in most scenarios.
</description><link>http://ayende.com/3318/rhino-mocks-arrange-act-assert-syntax#comment14</link><guid>http://ayende.com/3318/rhino-mocks-arrange-act-assert-syntax#comment14</guid><pubDate>Mon, 26 May 2008 21:34:04 GMT</pubDate></item><item><title>Brad Wilson commented on Rhino Mocks - Arrange, Act, Assert Syntax</title><description>I don't particularly like this:
  
  
userRepository.Stub(x =&gt; x.GetUserById(5)).Return(new User { Id = 5, Name = "ayende" })
  
  
Because it mixes together what could be considered an assertion (I expect them to ask for user ID 5) with the stubbing behavior (return this). As an alternative, I think I'd prefer:
  
  
userRepository.StubReturn(x =&gt; x.GetUserById, new User { Id = 5, Name = "ayende" })
  
  
And then add an assertion about things being called correctly to the bottom:
  
  
userRepository.AssertWasCalled(x =&gt; x.GetuserById(5))
</description><link>http://ayende.com/3318/rhino-mocks-arrange-act-assert-syntax#comment13</link><guid>http://ayende.com/3318/rhino-mocks-arrange-act-assert-syntax#comment13</guid><pubDate>Mon, 26 May 2008 19:23:54 GMT</pubDate></item><item><title>Onur Gumus commented on Rhino Mocks - Arrange, Act, Assert Syntax</title><description>After some thought here is my implementation:
  
  
 var mocks = new MockRepository();
  
            var view = MockRepository.GenerateMock&lt;ICBOTExchangeView&gt;();
  
            var provider = MockRepository.GenerateStub&lt;IExchangeProvider&gt;();
  
  
            var result = new List&lt;BaseFinanceData&gt;();
  
            result.Add(new BaseFinanceData(){ Sell=1.1M, Buy = 2.2M});
  
  
            view.Expect(v =&gt; v.CBOTExchangeRates).PropertyBehavior();
  
            var loadRaiser = view.Expect(v =&gt; v.CBOTExchangeRatesRequested += null).IgnoreArguments().GetEventRaiser();
  
  
            provider.Stub(p =&gt; p.GetCBOTExchangeRates()).Return(result);
  
  
            var presenter = new SmartInvest.Presenter.CBOTExchangeRatePresenter();
  
            presenter.View = view;
  
            presenter.ExchangeProvider = provider;
  
            loadRaiser.Raise(view, EventArgs.Empty);
  
  
            view.VerifyAllExpectations();            
  
            Assert.AreEqual(1, view.CBOTExchangeRates.Count);
  
</description><link>http://ayende.com/3318/rhino-mocks-arrange-act-assert-syntax#comment12</link><guid>http://ayende.com/3318/rhino-mocks-arrange-act-assert-syntax#comment12</guid><pubDate>Mon, 26 May 2008 12:58:30 GMT</pubDate></item><item><title>Onur Gumus commented on Rhino Mocks - Arrange, Act, Assert Syntax</title><description>How do I test events with this syntax. My old test case is as below (appliying Model View Presenter) Can you please guide me a little bit :
  
  
            var mocks = new MockRepository();
  
            var view = mocks.DynamicMock&lt;ICBOTExchangeView&gt;();
  
            var provider = mocks.DynamicMock&lt;IExchangeProvider&gt;();
  
  
                       SetupResult.For(view.CBOTExchangeRates).PropertyBehavior();
  
  
            var result = new List&lt;BaseFinanceData&gt;();
  
            result.Add(new BaseFinanceData(){ Sell=1.1M, Buy = 2.2M});
  
  
  
            view.CBOTExchangeRatesRequested += null; 
  
            var loadRaiser = LastCall.IgnoreArguments().GetEventRaiser();
  
  
            Expect.Call(provider.GetCBOTExchangeRates()).Return(result);
  
            mocks.ReplayAll();
  
  
            var presenter = new  CBOTExchangeRatePresenter();
  
            presenter.View = view;
  
            presenter.ExchangeProvider = provider;
  
            loadRaiser.Raise(view, EventArgs.Empty);
  
  
  
  
            Assert.AreEqual(1, view.CBOTExchangeRates.Count);
  
  
</description><link>http://ayende.com/3318/rhino-mocks-arrange-act-assert-syntax#comment11</link><guid>http://ayende.com/3318/rhino-mocks-arrange-act-assert-syntax#comment11</guid><pubDate>Mon, 26 May 2008 12:28:36 GMT</pubDate></item><item><title>Stanislav Dvoychenko commented on Rhino Mocks - Arrange, Act, Assert Syntax</title><description>Do with Action&lt;T&gt; would be nice to have, I'm trying the Beta but see only IMethodOptions&lt;T&gt; Do(Delegate action); which can't convert from lambda expression (and from anonymous delegate as well I guess?). God, it will be great to have lambda expressions everwhere.
</description><link>http://ayende.com/3318/rhino-mocks-arrange-act-assert-syntax#comment10</link><guid>http://ayende.com/3318/rhino-mocks-arrange-act-assert-syntax#comment10</guid><pubDate>Thu, 22 May 2008 19:22:03 GMT</pubDate></item><item><title>Ayende Rahien commented on Rhino Mocks - Arrange, Act, Assert Syntax</title><description>mock.AssertWasCalled(x =&gt; x.Name = "blah");
</description><link>http://ayende.com/3318/rhino-mocks-arrange-act-assert-syntax#comment9</link><guid>http://ayende.com/3318/rhino-mocks-arrange-act-assert-syntax#comment9</guid><pubDate>Thu, 22 May 2008 10:38:45 GMT</pubDate></item><item><title>Carel Lotz commented on Rhino Mocks - Arrange, Act, Assert Syntax</title><description>Is it possible to assert that a property setter was called using the new syntax?
</description><link>http://ayende.com/3318/rhino-mocks-arrange-act-assert-syntax#comment8</link><guid>http://ayende.com/3318/rhino-mocks-arrange-act-assert-syntax#comment8</guid><pubDate>Thu, 22 May 2008 07:46:30 GMT</pubDate></item><item><title>Neil Mosafi commented on Rhino Mocks - Arrange, Act, Assert Syntax</title><description>Great syntax, I love it!
</description><link>http://ayende.com/3318/rhino-mocks-arrange-act-assert-syntax#comment7</link><guid>http://ayende.com/3318/rhino-mocks-arrange-act-assert-syntax#comment7</guid><pubDate>Mon, 19 May 2008 21:51:57 GMT</pubDate></item><item><title>Ayende Rahien commented on Rhino Mocks - Arrange, Act, Assert Syntax</title><description>Depends on what you are trying to achieve.
  
This would return the same instance for all calls.
  
This is probably what you are trying to get:
  
  
factory.Stub((f) =&gt;f.CreateParameter()).Repeat.Any.Do( () =&gt; MockRepository.GenerateStub&lt;DbParameter&gt;());
  
</description><link>http://ayende.com/3318/rhino-mocks-arrange-act-assert-syntax#comment6</link><guid>http://ayende.com/3318/rhino-mocks-arrange-act-assert-syntax#comment6</guid><pubDate>Mon, 19 May 2008 21:03:32 GMT</pubDate></item><item><title>Stanislav Dvoychenko commented on Rhino Mocks - Arrange, Act, Assert Syntax</title><description>Will it be possible to have something like:
  
factory.StubAny((f) =&gt; f.CreateParameter()).Return(MockRepository.GenerateStub&lt;DbParameter&gt;());
  
  
The intent here would be to Stub Any call with this Return. Right now it looks like it is required to call Stub as many times as code under test will call it ...
</description><link>http://ayende.com/3318/rhino-mocks-arrange-act-assert-syntax#comment5</link><guid>http://ayende.com/3318/rhino-mocks-arrange-act-assert-syntax#comment5</guid><pubDate>Mon, 19 May 2008 20:59:49 GMT</pubDate></item><item><title>Jimmy Bogard commented on Rhino Mocks - Arrange, Act, Assert Syntax</title><description>I think this constraint syntax is finally viable.  It always bothered me to have my constraints mixed in with my setup code.  I want my assertions to be as clear as possible.
  
  
Looking good...though the name "GenerateStub" seems strange to me.  Here's hoping we all simultaneously and spontaneously adapt Meszaros' test double nomenclature.
</description><link>http://ayende.com/3318/rhino-mocks-arrange-act-assert-syntax#comment4</link><guid>http://ayende.com/3318/rhino-mocks-arrange-act-assert-syntax#comment4</guid><pubDate>Mon, 19 May 2008 16:31:15 GMT</pubDate></item><item><title>Ayende Rahien commented on Rhino Mocks - Arrange, Act, Assert Syntax</title><description>John,
  
Yes, we are going to remain backward compatible with the previous versions.
</description><link>http://ayende.com/3318/rhino-mocks-arrange-act-assert-syntax#comment3</link><guid>http://ayende.com/3318/rhino-mocks-arrange-act-assert-syntax#comment3</guid><pubDate>Sat, 17 May 2008 16:11:24 GMT</pubDate></item><item><title>John Chapman commented on Rhino Mocks - Arrange, Act, Assert Syntax</title><description>Ayende,
  
  
Awesome work.  The AssertWasCalled looks to be a godsend for me.  I've always wanted a way to verify just a single expectation at a time on a given mock.  It would allow me to use a single set up and then many tests with only a single expectation check, versus when there are are two expectations on a mock and now you need to verify both on the mock.  If there is another way now I would love to hear about it, for now I just look forward to your next release.
  
  
Good work!
  
  
For clarification, will both syntax options be available in the new release?  The above syntax as well as the old legacy syntax, or will everything need to move over?  I could see that causing some real issues for me as our project has a significant number of tests making sue of Rhino Mocks already.
</description><link>http://ayende.com/3318/rhino-mocks-arrange-act-assert-syntax#comment2</link><guid>http://ayende.com/3318/rhino-mocks-arrange-act-assert-syntax#comment2</guid><pubDate>Sat, 17 May 2008 14:48:45 GMT</pubDate></item><item><title>Jeremy Gray commented on Rhino Mocks - Arrange, Act, Assert Syntax</title><description>When it comes to more advanced argument validation I find myself waffling back and forth between the pros and cons of the WithConstraints and WithArgMatchingInTheLambda options so it is nice to see that both options will (?) be available.
  
  
Everything else is looking very nice, as much as I still have yet to be convinced of the merit of act/arrange/assert over the classic set-expectations/exercise/assert(&amp;verify) style, except perhaps for the simplicity of the very phrase "act/arrange/assert". :)
</description><link>http://ayende.com/3318/rhino-mocks-arrange-act-assert-syntax#comment1</link><guid>http://ayende.com/3318/rhino-mocks-arrange-act-assert-syntax#comment1</guid><pubDate>Fri, 16 May 2008 14:13:25 GMT</pubDate></item></channel></rss>