예제 #1
0
        public void ContainsSucceeds()
        {
            //Arrange
            string      assemblyName = null;
            string      typeName     = null;
            string      key          = TestsConstants.TestGuidName;
            string      resultKey    = null;
            ConfigLevel resultLevel  = ConfigLevel.CurrentSPWeb;

            MSPUtility.ExecuteRegisteredProxyOperationStringStringSPProxyOperationArgs = (assembly, type, args) =>
            {
                assemblyName = assembly;
                typeName     = type;
                var proxyArgs = args as ProxyArgs.ContainsKeyDataArgs;
                resultKey   = proxyArgs.Key;
                resultLevel = (ConfigLevel)proxyArgs.Level;
                return(true);
            };

            var target = new SandboxFarmPropertyBag();

            //Act
            bool result = target.Contains(key);

            //Assert
            Assert.AreEqual <string>(assemblyName, ProxyArgs.ContainsKeyDataArgs.OperationAssemblyName);
            Assert.AreEqual <string>(typeName, ProxyArgs.ContainsKeyDataArgs.OperationTypeName);
            Assert.AreEqual(key, resultKey);
            Assert.AreEqual(ConfigLevel.CurrentSPFarm, resultLevel);
            Assert.IsTrue(result);
        }
예제 #2
0
        public void GetIndexerSucceeds()
        {
            //Arrange
            string      assemblyName = null;
            string      typeName     = null;
            string      key          = TestsConstants.TestGuidName;
            string      resultKey    = null;
            ConfigLevel resultLevel  = ConfigLevel.CurrentSPWeb;
            string      targetValue  = "foobar";

            MSPUtility.ExecuteRegisteredProxyOperationStringStringSPProxyOperationArgs = (assembly, type, args) =>
            {
                assemblyName = assembly;
                typeName     = type;
                var proxyArgs = args as ProxyArgs.ReadConfigArgs;
                resultKey   = proxyArgs.Key;
                resultLevel = (ConfigLevel)proxyArgs.Level;
                return(targetValue);
            };

            var target = new SandboxFarmPropertyBag();

            //Act
            string result = target[key];

            //Assert
            Assert.AreEqual <string>(assemblyName, ProxyArgs.ReadConfigArgs.OperationAssemblyName);
            Assert.AreEqual <string>(typeName, ProxyArgs.ReadConfigArgs.OperationTypeName);
            Assert.AreEqual(key, resultKey);
            Assert.AreEqual(ConfigLevel.CurrentSPFarm, resultLevel);
            Assert.AreEqual(targetValue, result);
        }
예제 #3
0
        public void ContainsKeyWithNullKeyThrowsArgumentNullException()
        {
            //Arrange
            var target = new SandboxFarmPropertyBag();

            //Act
            bool result = target.Contains(null);

            //Assert caught by expected exception
        }
예제 #4
0
        public void RemoveThrowsInvalidOperationException()
        {
            //Arrange
            var target = new SandboxFarmPropertyBag();

            //Act
            target.Remove("foobar");

            //Assert caught by exception
        }
예제 #5
0
        public void SetIndexerWithNullThrowsArgumentNullException()
        {
            //Arrange
            var target = new SandboxFarmPropertyBag();

            //Act
            string result = target[null];

            //Assert caught by expected exception
        }
예제 #6
0
        public void SetIndexerThrowsInvalidOperationException()
        {
            //Arrange
            var target = new SandboxFarmPropertyBag();

            //Act
            target["foo"] = "bar";

            //Assert caught by expected exception
        }
예제 #7
0
        public void GetLevelSucceeds()
        {
            //Arrange
            var target = new SandboxFarmPropertyBag();

            //Act
            ConfigLevel level = target.Level;

            //Assert
            Assert.AreEqual <ConfigLevel>(ConfigLevel.CurrentSPFarm, level);
        }