diff --git a/X10D.Tests/src/ReflectionTests.cs b/X10D.Tests/src/ReflectionTests.cs new file mode 100644 index 0000000..da95110 --- /dev/null +++ b/X10D.Tests/src/ReflectionTests.cs @@ -0,0 +1,70 @@ +namespace X10D.Tests +{ + using System; + using System.ComponentModel; + using Microsoft.VisualStudio.TestTools.UnitTesting; + + /// + /// Tests for . + /// + [TestClass] + public class ReflectionTests + { + /// + /// Test for . + /// + [TestMethod] + public void GetDefaultValue() + { + var klass = new TestClass(); + + foreach (var property in klass.GetType().GetProperties()) + { + Assert.AreEqual("Foo", property.GetDefaultValue()); + } + } + + /// + /// Test for . + /// + [TestMethod] + public void GetDescription() + { + var klass = new TestClass(); + + foreach (var property in klass.GetType().GetProperties()) + { + Assert.AreEqual("Test description", property.GetDescription()); + } + } + + /// + /// Test for . + /// + [TestMethod] + public void SelectFromCustomAttribute() + { + var klass = new TestClass(); + + foreach (var property in klass.GetType().GetProperties()) + { + var value = property.SelectFromCustomAttribute(a => a.TestValue); + Assert.AreEqual("Bar", value); + } + } + + [AttributeUsage(AttributeTargets.Property)] + private sealed class TestAttribute : Attribute + { + public string TestValue { get; set; } + } + + private sealed class TestClass + { + [System.ComponentModel.Description("Test description")] + [DefaultValue("Foo")] + [Test(TestValue = "Bar")] + public string TestProperty { get; set; } + } + } +}