Exemplo n.º 1
0
        public void PropertyOperations()
        {
            PropertyValues properties = new PropertyValues();
            properties.Add("Package", "zip");
            properties.Add("Keywords", "production");
            properties.Add("Keywords", "application");
            database.SetProperties(EntityType.Project, 10, properties);

            properties = database.GetProperties(EntityType.Project, 10);
            Assert.AreEqual(2, properties.GetCodes().Count);
            Assert.AreEqual(1, properties.GetValues("Package").Count);
            Assert.AreEqual("zip", properties.GetValues("Package")[0]);
            Assert.AreEqual(2, properties.GetValues("Keywords").Count);
            Assert.AreEqual("application", properties.GetValues("Keywords")[0]);
            Assert.AreEqual("production", properties.GetValues("Keywords")[1]);

            properties = new PropertyValues();
            properties.Add("Package", "zip");
            properties.Add("Package", "msi");
            properties.Add("Keywords", "service");
            properties.Add("Status", "beta");
            database.SetProperties(EntityType.Project, 10, properties);

            properties = database.GetProperties(EntityType.Project, 10);
            Assert.AreEqual(3, properties.GetCodes().Count);
            Assert.AreEqual(2, properties.GetValues("Package").Count);
            Assert.AreEqual("msi", properties.GetValues("Package")[0]);
            Assert.AreEqual("zip", properties.GetValues("Package")[1]);
            Assert.AreEqual(1, properties.GetValues("Keywords").Count);
            Assert.AreEqual("service", properties.GetValues("Keywords")[0]);
            Assert.AreEqual(1, properties.GetValues("Status").Count);
            Assert.AreEqual("beta", properties.GetValues("Status")[0]);

            properties = new PropertyValues();
            database.SetProperties(EntityType.Project, 10, properties);

            properties = database.GetProperties(EntityType.Project, 10);
            Assert.AreEqual(0, properties.GetCodes().Count);
        }
        public void PropertyValuesContainer()
        {
            PropertyValues properties = new PropertyValues();
            properties.Add("key1", "oleg");

            Assert.AreEqual(1, properties.GetCodes().Count);
            Assert.AreEqual(1, properties.GetValues("key1").Count);
            Assert.AreEqual("oleg", properties.GetValues("key1")[0]);
            Assert.AreEqual(0, properties.GetValues("key2").Count);

            properties.Add("key1", "shuruev");
            properties.Add("key2", "hello");

            Assert.AreEqual(2, properties.GetCodes().Count);
            Assert.AreEqual(2, properties.GetValues("key1").Count);
            Assert.AreEqual("oleg", properties.GetValues("key1")[0]);
            Assert.AreEqual("shuruev", properties.GetValues("key1")[1]);
            Assert.AreEqual(1, properties.GetValues("key2").Count);
            Assert.AreEqual("hello", properties.GetValues("key2")[0]);

            properties.Clear("key1");
            properties.Clear("key3");

            Assert.AreEqual(1, properties.GetCodes().Count);
            Assert.AreEqual(1, properties.GetValues("key2").Count);
            Assert.AreEqual("hello", properties.GetValues("key2")[0]);

            foreach (string word in this.emptyWords)
            {
                TestHelper.Throws(delegate
                {
                    properties.Add(word, "hello");
                });

                TestHelper.Throws(delegate
                {
                    properties.Add("key1", word);
                });
            }
        }