I am getting an error that doesn't make sense to me and I didn't see
this problem addressed in the group.
Here is the method I am mocking:
bool CreateServer(string sUserName, string sPassword, object
vNewPassword, string sServer, bool bInteractive, string sLanguage, ref
object oServer, ref object oConnection);
It is the interface for a 3rd party vendor, so I don't have control
over the API.
So, the last 2 args are ref arguments and I need to provide stubs for
them.
Here is the unit test:
var serverMetadata = new CmsServerMetaData { OperatorId =
"operator", OperatorPassword = "pwd", LanguageCode = "ENU",
Name="report" };
var server = this.CreateInstance(serverMetadata);
cvsServer stubServer =
MockRepository.GenerateStub<cvsServer>();
cvsConnection stubConnection =
MockRepository.GenerateStub<cvsConnection>();
stubConnection.LoginState = LoginState.cpConnected;
this.MockApplication.Expect(app => app.CreateServer(
Arg<string>.Is.Equal( serverMetadata.OperatorId),
Arg<string>.Is.Equal
( serverMetadata.OperatorPassword),
Arg<object>.Is.Anything,
Arg<string>.Is.Equal(serverMetadata.Name),
Arg<bool>.Is.Anything,
Arg<string>.Is.Equal(serverMetadata.LanguageCode),
ref Arg<object>.Ref(Is.Anything(), stubServer).Dummy,
ref Arg<object>.Ref(Is.Anything(),
stubConnection).Dummy))
.Return(true);
server.Connect();
The exception message I get from RM is
System.InvalidOperationException: Argument 6 must be defined as: out
Arg<T>.Out(returnvalue).Dummy.
What doesn't make sense is that the 6th argument is neither a ref nor
an out argument, so I have no idea why RM is throwing this exception.
I have also tried this same setup using .Stub() instead of .Expect()
and got the same message.
Am I doing something wrong, or is this a bug?
Now, when I cease using Arg<T> for all these arguments and pass a ref
to a variable with .OutRef() it works as it should. For example:
this.MockApplication.Expect(app => app.CreateServer(
serverMetadata.OperatorId,
serverMetadata.OperatorPassword,
string.Empty,
serverMetadata.Name,
false,
serverMetadata.LanguageCode,
ref refStubServer,
ref refStubConnection))
.Return(true)
.OutRef(stubServer, stubConnection);
Thanks,
Jason
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---