Open douglasg14b opened 3 months ago
Similar thing happens with the example DateTime
shim:
Shim dateTimeShim = Shim.Replace(() => DateTime.UtcNow)
.With(() => new DateTime(2004, 4, 4));
DateTimeOffset.UtcNow.AddMonths(1);
throws something similar:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
---> System.NullReferenceException: Object reference not set to an instance of an object.
at impl_System.DateTimeOffset_AddMonths(DateTimeOffset&, Int32)
at stub_call_System.DateTimeOffset_AddMonths(DateTimeOffset&, Int32)
at impl_Buzzscreens.Features.Tests.Orders.OrderTests+<>c_<WithOrder_NextBillingDate_ReturnsCorrectDate>b__1_4(<>c)
at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
DateTime.UtcNow.AddMonths(1);
throws no such errors.
I tried reproducing locally using .NET 8.0. I did not encounter any exception. What is your target framework?
Additionally, what are the values of startDate
and monthIndex
?
It seems that something is messed up here.
Using
Poser
v2.1.0
The following works as expected: