public void ShouldCallCallbackIfNoCache() { var siteMock = new ShimSPSite(); var site = SaveDataJobExecuteCache.GetSiteFromCache(Guid.Empty, false, () => siteMock); site.ShouldBe(siteMock); site = SaveDataJobExecuteCache.GetSiteFromCache(Guid.Empty, true, () => siteMock); site.ShouldBe(siteMock); }
public void ShouldCallCallbackIfSiteOfDifferentId() { using (SaveDataJobExecuteCache.InitializeCache(new ShimSPSite())) { var siteId = Guid.NewGuid(); var siteMock = new ShimSPSite { IDGet = () => siteId }; var site = SaveDataJobExecuteCache.GetSiteFromCache(siteId, false, () => siteMock); site.ShouldBe(siteMock); site = SaveDataJobExecuteCache.GetSiteFromCache(siteId, true, () => siteMock); site.ShouldBe(siteMock); } }
public void ShouldReturnOriginalSiteForNonElevated() { var siteMock = new ShimSPSite(); using (SaveDataJobExecuteCache.InitializeCache(siteMock)) { var site = SaveDataJobExecuteCache.GetSiteFromCache(Guid.Empty, false, () => { Assert.Fail(); return(null); }); site.ShouldBe(siteMock); } }
public void ShouldReturnElevatedOnRequest() { var siteMock = new ShimSPSite(); ShimSPSite siteMockElevated = null; ShimSPSite.ConstructorGuid = (site, guid) => { siteMockElevated = new ShimSPSite(site); }; ShimSPSecurity.RunWithElevatedPrivilegesSPSecurityCodeToRunElevated = cb => cb(); using (SaveDataJobExecuteCache.InitializeCache(siteMock)) { var site = SaveDataJobExecuteCache.GetSiteFromCache(Guid.Empty, true, () => { Assert.Fail(); return(null); }); site.ShouldSatisfyAllConditions( () => site.ShouldNotBeNull(), () => site.ShouldBe(siteMockElevated), () => site.ShouldNotBe(siteMock)); } }