public void Cleanup() { SPSite spSite = new SPSite("http://localhost:9001/sites/pssportal"); SPContext spContext = SPContext.GetContext(spSite.RootWeb); Isolate.WhenCalled(() => SPContext.Current.Site).WillReturn(spSite); Isolate.WhenCalled(() => SPContext.Current).WillReturn(spContext); List <string> keys = new List <string>() { "IntegrationTest-FarmLevelKey", "IntegrationTest-WebAppLevelKey", "IntegrationTest-SiteLevelKey", "IntegrationTest-WebLevelKey" }; HierarchicalConfig hierarchicalConfig = new HierarchicalConfig(); foreach (string key in keys) { hierarchicalConfig.RemoveKeyFromPropertyBag(key, SPContext.Current.Web); hierarchicalConfig.RemoveKeyFromPropertyBag(key, SPContext.Current.Site); hierarchicalConfig.RemoveKeyFromPropertyBag(key, SPContext.Current.Site.WebApplication); hierarchicalConfig.RemoveKeyFromPropertyBag(key, SPFarm.Local); } Isolate.CleanUp(); }