Arg.Is.Equal type conversion
Here is a failing test for an issue that tripped me up for awhile.
The problem is that although I'm using Arg<long> userId is inferred by
the compiler to be an Int32 not Int64.
Could be nice enhancement to carry the type parameter through to
Is.Equal(T obj) or at least perhaps throw an exception.
[TestFixture]
public class ArgConstraintTest
{
[Test]
public void ConvertArgEqualParamToCorrectType()
{
const string user = "test";
var userId = 1; // inferred as Int32
var crossReferenceService =
MockRepository.GenerateStub<ITestService>();
crossReferenceService.Stub(x => x.GetUser
(Arg<long>.Is.Equal(userId))).Return(user);
var value = crossReferenceService.GetUser(userId);
Assert.That(value, Is.EqualTo(user));
}
public interface ITestService
{
string GetUser(long id);
}
}
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---