Im trying to mock a method, it compiles without errors, but smth strange happens when i run a test. Actually method doesnt mock or maybe I dont understand smth...(
Here's a code:
public class Robot
{ ....
public virtual bool range(IObs ob, double range)
{
double dist = ob.distanceSq(this);
if (dist < range)
return true;
else
return false;
}
}
...
public interface IObs
{
double distanceSq(Robot r);
}
...
Unit Test:
[TestClass]
public class UnitTest1
{
[TestMethod]
public void TestMethod1()
{
MockRepository mocks = new MockRepository();
IObs obstacleMock = mocks.CreateMock<IObs>();
Robot r = new Robot();
Expect.Call(obstacleMock.distanceSq(r)).IgnoreArguments()
.Constraints(Is.Anything())
.Return(5.5);
Assert.IsTrue(r.range(obstacleMock, 0.5));
}
}
I mock distanceSq(). When I debug my test, i see that ob.distanceSq(this) is 0.0. (not 1.5).
What's wrong?