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_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); }