我正在尝试创建 UserProfileManager 的模拟版本,以便有效地对 Sharepoint 2010 Web 部件进行单元测试 每次运行此代码时,都会在下面抛出异常。当我在 Sharepoint 机器上调试调用 UserProfileManager 的代码时,我已经验证了该功能有效——实际上是两台不同的 Sharepoint 机器。这是有问题的代码:
var _mockServiceContext = Mock.Create<SPServiceContext>();
var _mockUserProfileManager = Mock.Create<UserProfileManager>(new object[] {_mockServiceContext});
Unable to create instance of class SharePoint.MyWebPartTest. Error: Microsoft.SharePoint.SPException: The trial period for this product has expired..
at Microsoft.Office.Server.UserProfiles.ProfileManagerBase.ValidateLicensing()
at Microsoft.Office.Server.UserProfiles.ProfileManagerBase..ctor(SPServiceContext serviceContext)
at Microsoft.Office.Server.UserProfiles.ProfileManagerBase..ctor(SPServiceContext serviceContext, Boolean ignorePrivacy)
at Microsoft.Office.Server.UserProfiles.UserProfileManager..ctor(SPServiceContext serviceContext, Boolean IgnoreUserPrivacy, Boolean backwardCompatible)
at Microsoft.Office.Server.UserProfiles.UserProfileManager..ctor(SPServiceContext serviceContext)
at Castle.Proxies.UserProfileManagerProxy..ctor(IEventsMixin, IMockReplicator, IMockMixin, IInterceptor[], SPServiceContext)
at DynamicMethod_6f2d60ffa4f94cb4ba57556150461ef9(Object[])
at ...()
at ..[](Func`1 )
at ..(Type , Object[] )
at ..(Type , List`1 , Type , Object[] )
at ..(Type , Type[] , ProxyGenerationOptions , Object[] , IInterceptor[] )
at Telerik.JustMock.Core.MocksRepository.Create(Type , Object[] , IEnumerable`1 , IEnumerable`1 , IEnumerable`1 , Type[] , Boolean , Boolean , IEnumerable`1 )
at ..Create(MocksRepository , Type , Object[] , Nullable`1 , Type[] , Nullable`1 , IEnumerable`1 , List`1 , List`1 , List`1 )
at Telerik.JustMock.Mock..()
at ..[](Func`1 )
at Telerik.JustMock.Mock.Create(Object[] args)
有没有其他人看到这个问题?