Exemple #1
0
        public void TheAllProperty()
        {
            var metadataCollection = new ReflectionMetadataCollection(typeof(TestModel));

            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);
        }
Exemple #2
0
        public void TheGetMetadataMethod(string metadataName, bool shouldExist)
        {
            var metadataCollection = new ReflectionMetadataCollection(typeof(TestModel));
            var metadata           = metadataCollection.GetMetadata(metadataName);

            if (shouldExist)
            {
                Assert.IsNotNull(metadata);
            }
            else
            {
                Assert.IsNull(metadata);
            }
        }
Exemple #3
0
        public void TheGetValueMethod(string metadataName, object expectedValue)
        {
            var metadataCollection = new ReflectionMetadataCollection(typeof(TestModel));

            var model = new TestModel
            {
                ExistingProperty = "works",
                StringProperty   = null,
                IntProperty      = 42
            };

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

            Assert.AreEqual(expectedValue, actualValue);
        }