Smocks
Smocks copied to clipboard
Error: System.InvalidOperationException: Illegal operation due to the current state of the object
I'am trying to run this test:
[TestMethod] public void Test_MockStaticMethod_MethodMocked() { DateTime now = Smock.Run(context => { context.Setup(() => DateTime.Now).Returns(new DateTime(2000, 1, 1)); return DateTime.Now; }); Assert.AreEqual(now, DateTime.Now); }
but when the code try to execute this part of code:
DateTime now = Smock.Run(context => { context.Setup(() => DateTime.Now).Returns(new DateTime(2000, 1, 1)); return DateTime.Now; });
It throws an exception: System.InvalidOperationException: Illegal operation due to the current state of the object
Any help will be greatly appreciated.