tonerdo / pose

Replace any .NET method (including static and non-virtual) with a delegate
MIT License
1.07k stars 75 forks source link

Common Language Runtime detected an invalid program. #60

Open kristof12345 opened 4 years ago

kristof12345 commented 4 years ago

Hi!

I get an excepion when running my tests: System.InvalidProgramException : Common Language Runtime detected an invalid program.

My test is: // Set DateTime.Now Shim dateTimeShim = Shim.Replace(() => DateTime.Now).With(() => new DateTime(2020, 1, 1).AddHours(1));

        PoseContext.Isolate(async () =>
        {
            Assert.Equal(new DateTime(2020, 1, 1).AddHours(1), DateTime.Now);

            var result = await Repository.IncrementVotes();
            Assert.Equal(1, result);

            result = await Repository.IncrementVotes();
            Assert.Equal(2, result);

            result = await Repository.CountVotes();
            Assert.Equal(2, result);
        }, dateTimeShim);

Thanks.

Miista commented 5 months ago

For support for async/await please see https://github.com/Miista/pose/issues/12

cc: @madmox @mql4coder @karlfinnsson @misskaseyann @jmoralesv @lewis-hu @inqb @TakaGoto @tsawyer999 @josh-hoiland