문제

I have some 3-year old (poorly written) tests that uses RhinoMock 3.6. Today I upgraded to 3.6.1 and suddenly I got an ExpectationViolationException when running the tests.

The setup is:

var userid = user.Identifier;
UserRepository.
    Expect(x => x.GetUser(Arg.Is(userid), Arg.Is(long.MinValue), out Arg<bool>.Out(true).Dummy))
    .Return(user);

and the exception is

Rhino.Mocks.Exceptions.ExpectationViolationException : IUserRepository.GetUser(equal to 6a90efd1-a290-452a-a8ac-5b38377bc597, equal to -9223372036854775808, anything); Expected #1, Actual #0.

I have of course checked the values for the userid and it is ok. Downgrading to 3.6 makes the test pass.

Does any one know what could cause this problem?

도움이 되었습니까?

해결책

There were a couple of changes related to the way Rhino Mocks handles out and ref parameters in versions 3.6 and 3.6.1, so I would change the test approach to something like this:

var userid = user.Identifier;
UserRepository.Stub(x => x
      .GetUser(Arg.Is(userid), Arg.Is(long.MinValue), out myVar)
      .OutRef(valueForMyVar)
      .Return(user);

And if you really wanna make sure you're calling the method, you can use UserRepository.AssertWasCalled at the end of the test...

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top