Using RhinoMocks 3.6 (rhino rocks!!!) I've stumbled in a maybe strange
behavior, that I'm not sure if it's a kind of bug or it's me that I've
got some wrong assumptions.
I've this test, that works well as expected.
var repo = new MockRepository();
var coupler = repo.StrictMock<ICoupler>();
ITessera encoder = new TesseraMifare(coupler);
Assert.That(encoder, Is.Not.Null);
With.
Mocks(repo).
ExpectingInSameOrder(Procs.ForOpen(coupler)).
Verify(() => /* bla bla bla*/);
"Procs.ForOpen" contains a long list of Expect.Call, but the important
thing to know is all works well :)
Ive tried to reuse the same "Procs.ForOpen" funcion in another test
that actually do the same thing under the hood (the test is for a
factory that create the same object tested before), but the test
fails :(
I've checked how happens and looks like this Expect.Call (inside
"Procs.ForOpen"):
Expect.Call(coupler.Authenticate(0, 0, 0, out type, out buf, out
status)).
IgnoreArguments().
Return(-1). // PLEASE NOTE HERE!!
OutRef((byte)6, Consts.SerialNumber, 0);
In the first test returns -1, but in the second test returns 0!!!!
I've checked how this is possible (I repeat, I'm sure the called
mocked code is the same) and I've found the "bug".
The first test creates a StrictMock: var coupler =
repo.StrictMock<ICoupler>();
but the second uses a DynamicMock: var coupler =
repo.DynamicMock<ICoupler>();
I've changed the second test to use StrictMock and all works well now,
but I'm curious to know why using DynamicMock gegerate this behavior.
A side note: "Procs.ForOpen" contains more that one
"Expect.Call(coupler.Authenticate" all equal to the one specified
before. The first calls returns -1 as expected, then the behavior
changes and 0 is returned... looks a strange behavior to me.
Thanks for any help.
--
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.