quickLinksDA = new QuickLinksDA();
//setup a fake data context
var fakeDataContext = Isolate.Fake.Instance<EdxquicklinksDataContext>();
Isolate.Swap.NextInstance<EdxquicklinksDataContext>().With(fakeDataContext);
Isolate.WhenCalled(() => fakeDataContext.EDXQuickLinks)
.WillReturnCollectionValuesOf(fakeItems.AsQueryable());
Mock spSecurityMock = MockManager.Mock(typeof(SPSecurity));
spSecurityMock.MockMethodCalled += new MockMethodCalledEventHandler(
GSK.eDX.NUnit.TestUtil.spSecuritycMock_MockMethodCalled);
spSecurityMock.ExpectAlways("RunWithElevatedPrivileges");
SPSite fakeSite = Isolate.Fake.Instance<SPSite>(Members.ReturnRecursiveFakes);
Isolate.Swap.NextInstance<SPSite>().With(fakeSite);
SPWeb fakeWeb = Isolate.Fake.Instance<SPWeb>();
Isolate.WhenCalled(() => fakeSite.OpenWeb()).WillReturn(fakeWeb);
Isolate.WhenCalled(() => fakeWeb.Url).WillReturn(webUrl);
//Act
List<QuickLinksView> quickLinks = quickLinksDA.GetQuickLinks(
fileName, webUrl, role);
//Assert
Which in turn calling the below mentioned code: public static void spSecuritycMock_MockMethodCalled(object sender, MockMethodCallEventArgs e)
{
if (e.CalledMethodName.Equals("RunWithElevatedPrivileges"))
{
SPSecurity.CodeToRunElevated del = (SPSecurity.CodeToRunElevated)e.SentArguments[0];
IAsyncResult res = del.BeginInvoke(null, null);
res.AsyncWaitHandle.WaitOne();
del.EndInvoke(res);
}
}
Assert.AreEqual(4, quickLinks.Count);
I am getting the error from Bold and Underlined part