Dowload latest from trunk
On May 19, 2010, at 2:58 AM, Adriano Labate <[email protected]>
wrote:
Thank you for your answers.
I have the following test that works. The mock is an object
implementing two interfaces. The method under test (SendData) will
call the mock, first by setting the Attributes property passing a
List, then by calling its Execute method.
var repository = new MockRepository();
var mock =
repository.StrictMultiMock<IFooFirst>(typeof(IFooSecond));
((IFooSecond)mock).Attributes = new
List<IDictionary<string, object>>();
LastCall.IgnoreArguments();
Expect.Call(mock.Execute);
repository.ReplayAll();
ConnectorService service = new ConnectorService();
var attributesList = new AttributesList();
// ...
service.SendData(attributesList); // Calls mock.Execute
after setting Attributes property
repository.VerifyAll();
Now I tried to use the AAA style :
var repository = new MockRepository();
var mock =
repository.StrictMultiMock<IFooFirst>(typeof(IFooSecond));
mock.Expect(x => ((IFooSecond)x).Attributes = new
List<IDictionary<string, object>>()).IgnoreArguments();
mock.Expect(x => x.Execute());
ConnectorService service = new ConnectorService();
var attributesList = new AttributesList();
// ...
service.SendData(attributesList); // Calls mock.Execute
after setting Attributes property
mock.VerifyAllExpectations();
You notice that I used the normal style to create the mock because I
didn't found a method in MockRepository (only CreateMock, CreateStub),
there is no CreateMultiMock, for creating a mock implementing two
interfaces in AAA style.
The problem here is that I got a "This action is invalid when the mock
object is in record state" error on the last line.
This can be fixed by adding the line "repository.ReplayAll();" just
after the two mock.Expect(...) lines.
But it seems to me that it is not AAA anymore this way.
How could I write that test in pure AAA style?
Thanks
On 18 mai, 20:19, Tim Barcz <[email protected]> wrote:
Worth noting that I believe this Call is available in the trunk as a
straight AAA call.
On May 18, 2010, at 12:29 PM, Patrick Steele
<[email protected]> wrote:
Yeah, it worked. I originally didn't have the "ReplayAll" and got
an
error on the VerifyAllExpecations about the repository still being
in
a record state. Once I added the ReplayAll, it worked fine (and it
throws the appropriate exception if IFoo.Foo or IDisposable.Dispose
are not called in DoSomething).
---
Patrick Steele
http://weblogs.asp.net/psteele
On Tue, May 18, 2010 at 1:25 PM, Tim Barcz <[email protected]>
wrote:
Did that work? Wondering about how this would work with the
joining of AAA
and Record/Replay.
On Tue, May 18, 2010 at 12:22 PM, Patrick Steele
<[email protected]
wrote:
I think StrictMultiMock will work in this case. Here's a quick
example I
tried:
http://pastebin.com/8TS4tEpZ
---
Patrick Steele
http://weblogs.asp.net/psteele
On Tue, May 18, 2010 at 11:25 AM, Adriano Labate
<[email protected]> wrote:
Hello,
I can't find how to create a mock for a class implementing two
interfaces with the new AAA model in version 3.5.
Before 3.5, I called: CreateMultiMock<IFirstInterface>(typeof
(ISecondInterface))
Could I call this method when using the AAA model, or is there
another
way to get the same result?
Thanks
--
You received this message because you are subscribed to the Google
Groups
"Rhino.Mocks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rhinomocks?hl=en.
--
Tim Barcz
Microsoft C# MVP
Microsoft ASPInsider
http://timbarcz.devlicio.us
http://www.twitter.com/timbarcz
--
You received this message because you are subscribed to the Google
Groups
"Rhino.Mocks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rhinomocks?hl=en.
--
You received this message because you are subscribed to the Google
Groups "Rhino.Mocks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected]
.
For more options, visit this group athttp://groups.google.com/
group/rhinomocks?hl=en
.
--
You received this message because you are subscribed to the Google
Groups "Rhino.Mocks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to [email protected]
.
For more options, visit this group athttp://groups.google.com/group/
rhinomocks?hl=en.
--
You received this message because you are subscribed to the Google
Groups "Rhino.Mocks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to [email protected]
.
For more options, visit this group at http://groups.google.com/group/rhinomocks?hl=en
.
--
You received this message because you are subscribed to the Google Groups
"Rhino.Mocks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rhinomocks?hl=en.