Hi, mocking DateTime.Now doesn't work for me.
Here's the code
class Timer
{
public void Tick()
{
if (DateTime.Now == DateTime.MaxValue)
throw new Exception("End of time!");
}
}
[TestFixture]
public class MyTests
{
[Test, Isolated]
public void TestTimer()
{
Isolate.WhenCalled(() => DateTime.Now).WillReturn(DateTime.MaxValue);
var timer = new Timer();
timer.Tick();//should throw
}
}
And here's the exception:
------------------------------------------
TypeMock.TypeMockException :
*** No method calls found in recording block. Please check:
* Are you trying to fake a field instead of a property?
* Are you are trying to fake mscorlib type?
------------------------------------------
I'm using Typemock 5.3.5