public void AddAndRemove() { // Arrange SPFarmPropertyBag.ClearCache(); var f = new BSPConfiguredFarm(); var fssPO = new MSPPersistedObject(f.SettingStore); fssPO.Update = () => { }; string key = "foo"; // create a farm with property 'key' f.SettingStore.Settings[key] = "fred"; // Act var target = new SPFarmPropertyBag(); var containsBeforeCondition = target.Contains(key); target.Remove(key); var result = target.Contains(key); // Assert Assert.IsFalse(result); Assert.IsTrue(containsBeforeCondition); }
public void AddAndRemove() { //Arrange SPWebAppPropertyBag.ClearCache(); MSPPersistedObject webPO; WebAppSettingStore wss; string key = "flintstone"; var webApp = new BSPConfiguredWebApp(); wss = new WebAppSettingStore(); wss.Settings[key] = "fred"; webPO = new MSPPersistedObject((SPPersistedObject)webApp.Instance); webPO.GetChildString <WebAppSettingStore>((s) => wss); var wssPO = new MSPPersistedObject(wss); wssPO.Update = () => { }; // Act var target = new SPWebAppPropertyBag(webApp); var containsBeforeCondition = target.Contains(key); target.Remove(key); var result = target.Contains(key); // Assert Assert.IsFalse(result); Assert.IsTrue(containsBeforeCondition); }
public void AddAndContains() { //Arrange SPWebAppPropertyBag.ClearCache(); MSPPersistedObject webPO; WebAppSettingStore wss; var webApp = new BSPConfiguredWebApp(); wss = new WebAppSettingStore(); webPO = new MSPPersistedObject((SPPersistedObject)webApp.Instance); webPO.GetChildString <WebAppSettingStore>( (s) => { return(wss); }); var wssPO = new MSPPersistedObject(wss); wssPO.Update = () => { }; string key = "key"; string value = "value"; var target = new SPWebAppPropertyBag(webApp); IPropertyBagTest.AddContains(target, key, value); }
public void Execute_ContainsKeyReturnsFalse_WithValidKeyNotSetAtWebAppLevel() { //arrange var args = new ContainsKeyDataArgs(); string key = ConfigManager.PnPKeyNamespace + "." + TestsConstants.TestGuidName; args.Key = key; args.Level = (int)ConfigLevel.CurrentSPWebApplication; args.SiteId = TestsConstants.TestGuid; var proxyOp = new ContainsKeyOperation(); var webApp = new BSPWebApplication(); WebAppSettingStore wss = new WebAppSettingStore(); var webPO = new MSPPersistedObject((SPPersistedObject)webApp.Instance); MSPSite.ConstructorGuid = (instance, guid) => { var site = new MSPSite(instance) { WebApplicationGet = () => { webPO.GetChildString <WebAppSettingStore>((s) => wss); return(webApp); }, Dispose = () => { } }; }; //Act var target = proxyOp.Execute(args); //Assert Assert.IsInstanceOfType(target, typeof(bool)); Assert.IsFalse((bool)target); }
public BSPConfiguredFarm() { BSPFarm.SetLocal(); fss = new FarmSettingStore(); mfarmpo = new MSPPersistedObject(BSPFarm.Local); mfarmpo.GetChildString <FarmSettingStore>((s) => fss); }
public void AddAndContains() { SPFarmPropertyBag.ClearCache(); var f = new BSPConfiguredFarm(); var fssPO = new MSPPersistedObject(f.SettingStore); fssPO.Update = () => { }; string key = "key"; string value = "value"; var target = new SPFarmPropertyBag(); IPropertyBagTest.AddContains(target, key, value); }
public void Execute_ReturnsKeyData_WithValidKeyAtWebAppLevel() { //arrange SPWebAppPropertyBag.ClearCache(); var args = new ReadConfigArgs(); string key = ConfigManager.PnPKeyNamespace + "." + TestsConstants.TestGuidName; args.Key = key; args.Level = (int)ConfigLevel.CurrentSPWebApplication; args.SiteId = TestsConstants.TestGuid; var proxyOp = new ReadConfigurationOperation(); string expectedData = "{92700BB6-B144-434F-A97B-5F696068A425}"; MSPPersistedObject webPO; WebAppSettingStore wss; MSPSite.ConstructorGuid = (instance, guid) => { var site = new MSPSite(instance) { WebApplicationGet = () => { var webApp = new BSPConfiguredWebApp(); wss = new WebAppSettingStore(); wss.Settings[key] = expectedData; webPO = new MSPPersistedObject((SPPersistedObject)webApp.Instance); webPO.GetChildString <WebAppSettingStore>((s) => wss); return(webApp); }, Dispose = () => { } }; }; //Act object target = proxyOp.Execute(args); //Assert . Assert.IsInstanceOfType(target, typeof(string)); Assert.AreEqual(expectedData, (string)target); }
public void Execute_ReturnsNull_WithValidKeyNotSetAtWebAppLevel() { //arrange SPWebAppPropertyBag.ClearCache(); var args = new ReadConfigArgs(); string key = ConfigManager.PnPKeyNamespace + "." + TestsConstants.TestGuidName; args.Key = key; args.Level = (int)ConfigLevel.CurrentSPWebApplication; args.SiteId = TestsConstants.TestGuid; var proxyOp = new ReadConfigurationOperation(); MSPPersistedObject webPO; WebAppSettingStore wss; MSPSite.ConstructorGuid = (instance, guid) => { var site = new MSPSite(instance) { WebApplicationGet = () => { var webApp = new BSPConfiguredWebApp(); wss = new WebAppSettingStore(); webPO = new MSPPersistedObject((SPPersistedObject)webApp.Instance); webPO.GetChildString <WebAppSettingStore>((s) => wss); return(webApp); }, Dispose = () => { } }; }; //Act object target = proxyOp.Execute(args); //Assert Assert.IsNull(target); }