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); }
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); } }
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); }