I have a unit test in which I am generating some mocks
using .GenerateMock<>(). If I run the unit test alone (ie. not other
tests before or after) then the test passes. But when I run then
entire suite, the test fails. Let me start with a bit of the test
code:
ICountryDataCache countryDataCache =
MockRepository.GenerateMock<ICountryDataCache>();
countryDataCache.Expect(x =>
x.GetCountryIdFromName("Canada")).Repeat.Any().Return(canadaId);
countryDataCache.Expect(x =>
x.GetCountryIdFromName(Constants.WellKnownLabels.UnitedStates)).Return(usId);
childContainer.RegisterInstance(countryDataCache);
I enable logging with RhinoMocks.Logger, and when I run the test
alone, I get this output.
Recorded expectation:
ICountryDataCache.GetCountryIdFromName("Canada");
Recorded expectation:
ICountryDataCache.GetCountryIdFromName("United States");
...
Replayed expectation:
ICountryDataCache.GetCountryIdFromName("Canada");
...
Replayed expectation:
ICountryDataCache.GetCountryIdFromName("United States");
That's what I would expect. However, when I run the entire suite, the
output is different:
Recorded expectation:
ICountryDataCache.GetCountryIdFromName("Canada");
Recorded expectation:
ICountryDataCache.GetCountryIdFromName("United States");
...
Stub Mock: Unexpected method call ignored:
ICountryDataCache.GetCountryIdFromName("Canada");
...
Stub Mock: Unexpected method call ignored:
ICountryDataCache.GetCountryIdFromName("United States");
So this is what I don't understand; it's the same code, but the
logging shows it as a "Stub Mock", and then tells me that it was an
unexpected method call. Can anyone explain this?
--
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.