Hello together
I'm just trying to mock the SPContentTypeCollection class out of the SharePoint 2010 assembly but I'm facing a problem arranging a mock for the "BestMatch" method. I've already searched for a solution but cannot find any information about it.
This is my testcode:
The first three lines work perfectly, but an error is thrown for the fourth line. The mockedList is being creatd within a "TestInitialize" method.
This ist the call stack for the error occuring:
Has someone face the same problem already and / or can someone help me finding a solution?
Thanks
Andreas
I'm just trying to mock the SPContentTypeCollection class out of the SharePoint 2010 assembly but I'm facing a problem arranging a mock for the "BestMatch" method. I've already searched for a solution but cannot find any information about it.
This is my testcode:
SPContentTypeCollection mockedContentTypeCollection = Mock.Create<SPContentTypeCollection>();Mock.Arrange(() => mockedList.ContentTypes).Returns(mockedContentTypeCollection);SPContentTypeId mockedContentTypeId = Mock.Create<SPContentTypeId>();Mock.Arrange(() => mockedContentTypeCollection.BestMatch(Arg.IsAny<SPContentTypeId>())).Returns(mockedContentTypeId).MustBeCalled();The first three lines work perfectly, but an error is thrown for the fourth line. The mockedList is being creatd within a "TestInitialize" method.
This ist the call stack for the error occuring:
Test method XX.XX.Data.Tests.Repositories.XXRepositoryTests.AddPaymentSucceedsTest threw exception: System.NullReferenceException: Object reference not set to an instance of an object.at Telerik.JustMock.Weaver.Interceptors.WeaverInterceptor.GetRuntimeMethod(IInvocation invocation)at Telerik.JustMock.Weaver.Interceptors.WeaverInterceptor.Telerik.JustMock.Weaver.Interceptors.Abstraction.IWeaverInterceptor.Intercept(IInvocation invocation)at SPContentTypeId_Interceptor_d2e70383884d4efca5b3ddb76451ab0c.Intercept(Object, SPContentTypeId, ref Boolean)at Microsoft.SharePoint.SPContentTypeId.Equals(Object o)at Telerik.JustMock.Utility.IsDefault(Type valueType, Object value)at Telerik.JustMock.Setup.MethodCall.GetNewInstance(Object[] arguments, Type[] argumentTypes)at Telerik.JustMock.Interceptors.MockInterceptor.CreateMethodInstance(Object[] userArgs, Type[] types)at Telerik.JustMock.Interceptors.MockInterceptor.CreateMethodInstance(Object[] userArgs, Type[] types, Instruction instruction)at Telerik.JustMock.Interceptors.MockInterceptor.Intercept(MockInvocation invocation)at Telerik.JustMock.Weaver.Interceptors.WeaverInterceptor.Telerik.JustMock.Weaver.Interceptors.Abstraction.IWeaverInterceptor.Intercept(IInvocation invocation)at Telerik.JustMock.Handlers.WeaverInterceptorHandler.Invoke(Object[] args)at Telerik.JustMock.MockContext`1.SetupMock(MockExpression`1 expression)at Telerik.JustMock.MockContext`1.SetupMock(Expression`1 expression)at Telerik.JustMock.Mock.<>c__DisplayClass1`1.<Arrange>b__0(MockContext`1 x)at Telerik.JustMock.MockContext.Setup(Instruction instruction, Func`2 function)at Telerik.JustMock.Mock.Arrange(Expression`1 expression)at XX.XX.Data.Tests.Repositories.XXRepositoryTests.AddPaymentSucceedsTest() in XXRepositoryTests.cs: line 163Has someone face the same problem already and / or can someone help me finding a solution?
Thanks
Andreas