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 void Execute_ThrowsArgumentNullException_WhenArgsAreNull() { var proxyOp = new ContainsKeyOperation(); //Act proxyOp.Execute(null); //Assert caught by exception... }
public void Execute_ReturnsConfigurationException_WhenWrongArgTypeProvided() { var proxyOp = new ContainsKeyOperation(); var args = new ReadConfigArgs(); //Act object result = proxyOp.Execute(args); //Assert Assert.IsInstanceOfType(result, typeof(ConfigurationException)); }
public void executeOperationTest() { TCPTransport trans = new TCPTransport(System.Net.IPAddress.Loopback, 11222); Codec codec = new Codec(); byte[] key = UTF8Encoding.UTF8.GetBytes("key10"); ContainsKeyOperation target = new ContainsKeyOperation(codec, key, null, 0, null); Transport transport = trans; bool expected = false; bool actual; actual = target.executeOperation(transport); Assert.AreEqual(expected, actual); }
/// <summary> /// Checks whether the passes key exists in the cache /// </summary> /// <param name="key">Key</param> /// <returns>True if the passed key exixts. False if not exist.</returns> public bool containsKey(Object key) { ContainsKeyOperation op = operationsFactory.newContainsKeyOperation(serializer.serialize(key)); transport = transportFactory.getTransport(); try { } finally { transportFactory.releaseTransport(transport); } return((Boolean)op.executeOperation(transport)); }
public void Execute_ReturnsConfigurationException_WhenSiteIdIsEmpty() { var proxyOp = new ContainsKeyOperation(); var args = new ContainsKeyDataArgs(); args.Key = ConfigManager.PnPKeyNamespace + "." + TestsConstants.TestGuidName; args.Level = (int)ConfigLevel.CurrentSPWebApplication; //Act object result = proxyOp.Execute(args); //Assert Assert.IsInstanceOfType(result, typeof(ConfigurationException)); }
public void Execute_ReturnsArgumentNullException_WhenKeyIsNull() { var proxyOp = new ContainsKeyOperation(); var args = new ContainsKeyDataArgs(); args.Key = null; args.SiteId = TestsConstants.TestGuid; args.Level = (int)ConfigLevel.CurrentSPWebApplication; //Act object result = proxyOp.Execute(args); //Assert Assert.IsInstanceOfType(result, typeof(ArgumentNullException)); }
public void Execute_ReturnsConfigurationException_WithInvalidLevel() { //arrange var args = new ContainsKeyDataArgs(); string key = ConfigManager.PnPKeyNamespace + "." + TestsConstants.TestGuidName; var proxyOp = new ContainsKeyOperation(); args.Key = key; args.Level = (int)ConfigLevel.CurrentSPWeb; args.SiteId = TestsConstants.TestGuid; //Act var target = proxyOp.Execute(args); //Assert Assert.IsInstanceOfType(target, typeof(ConfigurationException)); }
public void Execute_ReturnsAConfigurationException_WhenKeyDoesntHaveNamespace() { //arrange var args = new ContainsKeyDataArgs(); args.Key = TestsConstants.TestGuidName; args.Level = (int)ConfigLevel.CurrentSPWebApplication; args.SiteId = TestsConstants.TestGuid; var proxyOp = new ContainsKeyOperation(); //Act var ex = proxyOp.Execute(args); //Assert Assert.IsInstanceOfType(ex, typeof(ConfigurationException)); }
public void Execute_ContainsKeyReturnsFalse_WithValidKeyNotSetAtFarmLevel() { //arrange var args = new ContainsKeyDataArgs(); string key = ConfigManager.PnPKeyNamespace + "." + TestsConstants.TestGuidName; var proxyOp = new ContainsKeyOperation(); var f = new BSPConfiguredFarm(); args.Key = key; args.Level = (int)ConfigLevel.CurrentSPFarm; args.SiteId = TestsConstants.TestGuid; //Act var target = proxyOp.Execute(args); //Assert Assert.IsInstanceOfType(target, typeof(bool)); Assert.IsFalse((bool)target); }
public void Execute_ContainsKeyReturnsTrue_WithValidKeyAtWebAppLevel() { //arrange SPWebAppPropertyBag.ClearCache(); 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(); string expectedData = "{92700BB6-B144-434F-A97B-5F696068A425}"; var webApp = new BSPWebApplication(); WebAppSettingStore wss = new WebAppSettingStore(); var webPO = new MSPPersistedObject((SPPersistedObject)webApp.Instance); wss.Settings[key] = expectedData; 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.IsTrue((bool)target); }
public void Execute_ContainsKeyReturnsTrue_WithValidKeyAtFarmLevel() { //arrange SPFarmPropertyBag.ClearCache(); var args = new ContainsKeyDataArgs(); string key = ConfigManager.PnPKeyNamespace + "." + TestsConstants.TestGuidName; var proxyOp = new ContainsKeyOperation(); var f = new BSPConfiguredFarm(); string expectedData = "{92700BB6-B144-434F-A97B-5F696068A425}"; args.Key = key; args.Level = (int)ConfigLevel.CurrentSPFarm; args.SiteId = TestsConstants.TestGuid; f.SettingStore.Settings[key] = expectedData; //Act var target = proxyOp.Execute(args); //Assert Assert.IsInstanceOfType(target, typeof(bool)); Assert.IsTrue((bool)target); }