Smocks icon indicating copy to clipboard operation
Smocks copied to clipboard

Error: System.InvalidOperationException: Illegal operation due to the current state of the object

Open dm-conti opened this issue 5 years ago • 0 comments

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.

dm-conti avatar Apr 09 '19 08:04 dm-conti