I'm working on a test case against a static method that makes a few calls on an object, and I'm trying to make those calls do nothing. The issue I'm having is that this:
TransactionHeaderViewModel
ticket = Mock.Create<TransactionHeaderViewModel>();
fails with the following:
Test method POSUnitTests.TransactionServiceTest.SaveTransactionTest threw exception: System.NullReferenceException: Object reference not set to an instance of an object..
Telerik.JustMock.DynamicProxy.MethodInvocation.Continue() in c:\B\Basilisk\Basilisk CI Build\Sources\CodeBase\Telerik.JustMock\DynamicProxy\MethodInvocation.cs: line 150
Intercept(IInvocation invocation) in c:\B\Basilisk\Basilisk CI Build\Sources\CodeBase\Telerik.JustMock\Interceptors\ProxyInterceptor.cs: line 35
TransactionHeaderViewModel_Proxy_a39192a5eca04cbbb79efb55f2387785.GetHashCode(MethodInvocation , Int32 , Boolean )
TransactionHeaderViewModel_Proxy_a39192a5eca04cbbb79efb55f2387785.GetHashCode()
get_Instance() in c:\B\Basilisk\Basilisk CI Build\Sources\CodeBase\Telerik.JustMock\MockObject.cs: line 44
Telerik.JustMock.Mock.Create(Type target, BehaviorMode mode, Object[] args) in c:\B\Basilisk\Basilisk CI Build\Sources\CodeBase\Telerik.JustMock\Mock.cs: line 354
Telerik.JustMock.Mock.Create(Type target, Object[] args) in c:\B\Basilisk\Basilisk CI Build\Sources\CodeBase\Telerik.JustMock\Mock.cs: line 339
Telerik.JustMock.Mock.Create[T]() in c:\B\Basilisk\Basilisk CI Build\Sources\CodeBase\Telerik.JustMock\Mock.cs: line 328
POSUnitTests.TransactionServiceTest.SaveTransactionTest() in c:\tfs\Point of Sale\POSApp\Main\Source\POSUnitTests\TransactionServiceTest.cs: line 151
If I just do a
TransactionHeaderViewModel ticket = new TransactionHeaderViewModel(); instead, then the calls to Mock.Arrange(() => ticket.SetLineNumbers()).DoNothing(); don't actually work, when debugging the test case you can see that the actual code is called. I also tried making SetLineNumbers() a virtual, but that caused the "Opps" error.
I thought that it was having an issue with what the constructor was doing, so I commented out everything in the constructor, but still get the same error (in fact, the error above is from that simplified case).
Any thoughts, or is this something that's already fixed in the current builds? I'm on the 528.5 beta release.
Thanks,
Justin