Hi,
I'm pretty new to TypeMock so bear with me if i'm doing some crappy stuff :)
here is what i'm doing to Fake some SharePoint Objects :
private Microsoft.SharePoint.SPWeb FakeSite_RootWeb() {
SPWeb fakeWeb = Isolate.Fake.Instance<SPWeb>(Members.ReturnRecursiveFakes);
Isolate.WhenCalled(() => fakeWeb.Title).WillReturn("Intranet");
Isolate.WhenCalled(() => fakeWeb.Description).WillReturn("Description Intranet");
Isolate.WhenCalled(() => fakeWeb.Language).WillReturn(1036);
Isolate.WhenCalled(() => fakeWeb.Lists).WillReturn(this.FakeSite_RootWeb_Lists());
return fakeWeb;
}
private Microsoft.SharePoint.SPListCollection FakeSite_RootWeb_Lists() {
SPListCollection fakeListCollection = Isolate.Fake.Instance<SPListCollection>(Members.ReturnRecursiveFakes);
Isolate.WhenCalled(() => fakeListCollection[0]).WillReturn(this.FakeSite_RootWeb_Lists_QuizzCategories());
string FakeSite_rootweb_lists_quizzcategories = "Quizz Catégories";
Isolate.WhenCalled(() => fakeListCollection[FakeSite_rootweb_lists_quizzcategories]).WillReturn(fakeListCollection[0]);
Isolate.WhenCalled(() => fakeListCollection[1]).WillReturn(this.FakeSite_RootWeb_Lists_QuizzAnimaux());
string FakeSite_rootweb_lists_quizzanimaux = "Quizz Animaux";
Isolate.WhenCalled(() => fakeListCollection[FakeSite_rootweb_lists_quizzanimaux]).WillReturn(fakeListCollection[1]);
return fakeListCollection;
}
this.FakeSite_RootWeb_Lists_QuizzCategories() return a SPList with 3 items
this.FakeSite_RootWeb_Lists_QuizzAnimaux() return a SPList with 2 items
I want to be able to get each SPList in SPListCollection via index or/and via name.
but as soon as i'm using Isolate.WhenCalled(() => fakeListCollection["Any string, even Empty"].... it will get the lastest fakeList i assigned to it.
Am i doing something wrong ?
Should i use WillReturnCollectionValuesOf somewhere (like in Isolate.WhenCalled(() => fakeWeb.Lists).WillReturn(this.FakeSite_RootWeb_Lists())) ?