Пример #1
0
            public void ConvertsFlatMetadataCollectionToList()
            {
                var objectWithMetadata = DictionaryMetadataFactory.CreateFlatObjectWithMetadata();

                var flatList = objectWithMetadata.ToStaticMetadataList();

                Assert.AreEqual(3, flatList.Count);
                Assert.AreEqual(null, flatList[0].Value);
                Assert.AreEqual(42, flatList[1].Value);
                Assert.AreEqual("works", flatList[2].Value);
            }
Пример #2
0
            public void ConvertsFlatMetadataCollectionToList()
            {
                var objectWithMetadata = DictionaryMetadataFactory.CreateFlatObjectWithMetadata();

                var dictionary = objectWithMetadata.ToStaticMetadataDictionary();

                Assert.AreEqual(3, dictionary.Count);
                Assert.AreEqual(null, dictionary["StringProperty"].Value);
                Assert.AreEqual(42, dictionary["IntProperty"].Value);
                Assert.AreEqual("works", dictionary["ExistingProperty"].Value);
            }
Пример #3
0
        public void TheAllProperty()
        {
            var metadataCollection = DictionaryMetadataFactory.CreateMetadataCollection();

            var all = metadataCollection.All.ToList();

            Assert.AreEqual(3, all.Count);
            Assert.AreEqual("StringProperty", all[0].Name);
            Assert.AreEqual("IntProperty", all[1].Name);
            Assert.AreEqual("ExistingProperty", all[2].Name);
        }
Пример #4
0
        public void TheGetMetadataMethod(string metadataName, bool shouldExist)
        {
            var metadataCollection = DictionaryMetadataFactory.CreateMetadataCollection();
            var metadata           = metadataCollection.GetMetadata(metadataName);

            if (shouldExist)
            {
                Assert.IsNotNull(metadata);
            }
            else
            {
                Assert.IsNull(metadata);
            }
        }
Пример #5
0
        public void TheGetValueMethod(string metadataName, object expectedValue)
        {
            var metadataCollection = DictionaryMetadataFactory.CreateMetadataCollection();

            var dictionary = new Dictionary <string, object>();

            dictionary["ExistingProperty"] = "works";
            dictionary["StringProperty"]   = null;
            dictionary["IntProperty"]      = 42;

            var metadata    = metadataCollection.GetMetadata(metadataName);
            var actualValue = metadata.GetValue(dictionary);

            Assert.AreEqual(expectedValue, actualValue);
        }
Пример #6
0
            public void ConvertsHierarchicalMetadataCollectionToList()
            {
                var objectWithMetadata = DictionaryMetadataFactory.CreateHierarchicalObjectWithMetadata();

                var dictionary = objectWithMetadata.ToStaticMetadataDictionary();

                Assert.AreEqual(3, dictionary.Count);

                Assert.AreEqual("#FFFF0000", dictionary["Name"].Value);
                Assert.AreEqual("#FFFF0000", dictionary["RGB"].Value);

                var subDictionary = (Dictionary <string, IMetadataValue>)dictionary["Color"].Value;

                Assert.AreEqual(4, subDictionary.Count);
                Assert.AreEqual(255, subDictionary["A"].Value);
                Assert.AreEqual(255, subDictionary["R"].Value);
                Assert.AreEqual(0, subDictionary["G"].Value);
                Assert.AreEqual(0, subDictionary["B"].Value);
            }