This is my first post in the Typemock forum. I'm completely new to Typemock, .Net and Sharepoint. Any help would be appreciated.
I have installed the Typemock for SharePoint and hooked it up with VS2008. I tried to run a very simple test, but I've been getting exception and could not get around it...
Below is the input, output and config (sorry about formatting):
public class SomeTest
Public void DummyTest()
SPWeb web = Isolator.Fake>Instance<SPWeb>(Members.ReturnRecursiveFakes);
SPList fakedSPList = Isolate.Fake.Instance<SPList>();
Isolate.WhenCalled(() => web.Lists["List"]).WillReturn(fakedSPList);
I ran that, and got the following error:
System.NullReferenceException: Ob ject reference not set to an instance of an object..
Microsoft.SharePoint.SPWeb.SPWebConstructor(SPSite site, String url, Boolean bExactWebUrl, SPRequest request)
Microsoft.SharePoint.SPWeb..ctor(SPSite, site, String url)
eo.CreateFakeInstance[T](Members behavior, Constructor constructorFlag, Constructor baseConstructorFlag, Type baseType, Object ctorArgs)
(Points to the SPWeb web line as source of error)
TypeMock.MockManager.a(String A_0, String A_1, Object A_2, Object A_3, Boolean A_4, Object A_5)
TypeMock.InternalMockManager.getReturn(Object that, String typeName, String methodNAme, Object methodParameters, Boolean isInjected)
(Points to line 0 of my test class)
I have added TypeMock, Typemock.ArrangeActAssert and Typemock.CLI.Common into my Reference.
I have no ideas whats going on. If I leave the SPWeb code out, the SPList works properly (I can see a whole heap of stuff getting mocked in the trace). But I just couldn't mock the SPWeb object. Please help!!