I have to admit, I'm not entirely sure what's going on here, but using Rhino. Mocks 3.6 and the newer syntax, it works fine for me: Test public void TestMyMethod() { MockRepository mocks = new MockRepository(); BaseWorker mock = mocks.StrictMock(); MyClass myClass = new MyClass(mock); string testData = "SomeData"; int expResponse = 10; using (mocks.Record()) { //I want to verify, that the method forwards the input to the worker //and returns the result of the call Expect. Call(mock.
DoWork(testData)). Return(expResponse); } using (mocks.Playback()) { int realResp = myClass. MethodToTest(testData); Assert.
AreEqual(expResponse, realResp); } } It doesn't have anything to do with the Rhino. Mocks version. With the old syntax, I get the same error as you're getting.
I didn't spot any obvious errors in your code, but then again, I'm used to this using syntax Edit : removed the var keyword, since you're using . NET 2.0.
I have to admit, I'm not entirely sure what's going on here, but using Rhino. Mocks 3.6 and the newer syntax, it works fine for me: Test public void TestMyMethod() { MockRepository mocks = new MockRepository(); BaseWorker mock = mocks.StrictMock(); MyClass myClass = new MyClass(mock); string testData = "SomeData"; int expResponse = 10; using (mocks.Record()) { //I want to verify, that the method forwards the input to the worker //and returns the result of the call Expect. Call(mock.
DoWork(testData)). Return(expResponse); } using (mocks.Playback()) { int realResp = myClass. MethodToTest(testData); Assert.
AreEqual(expResponse, realResp); } } It doesn't have anything to do with the Rhino. Mocks version. With the old syntax, I get the same error as you're getting.
I didn't spot any obvious errors in your code, but then again, I'm used to this using syntax. Edit: removed the var keyword, since you're using . NET 2.0.
Weird ... I tried almost your approach, just instead of using an own MockRepository, I was using the static GenerateStrictMock, and later, in the using statements I used mock. GetMockRepository(). Record/Replay, and it fails with "Rhino.Mocks.Exceptions.
ExpectationViolationException : BaseWorker. DoWork("SomeData"); Expected #0, Actual #1. ".
Your approach works ...but I'm even more confused now ... anyway ... it works, thanks. – Sunny Aug 9 '10 at 12:24.
I'm trying to test if the method I want to test calls some external (mock) object properly. The exception is thrown on the Expect. Call line, before any invocation is made.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.