Exemplo n.º 1
0
        public void GetCustomAttributesOnTypeShouldReturnAllAttributes()
        {
            var tinfo = typeof(ReflectionUtilityTests.DummyBaseTestClass).GetTypeInfo();

            var attribs = this.reflectionOperations.GetCustomAttributes(tinfo, false);

            Assert.IsNotNull(attribs);
            Assert.AreEqual(1, attribs.Length);

            var expectedAttribs = new string[] { "DummyA : ba" };

            CollectionAssert.AreEqual(expectedAttribs, ReflectionUtilityTests.GetAttributeValuePairs(attribs));
        }
Exemplo n.º 2
0
        public void GetSpecificCustomAttributesOnAssemblyShouldReturnAllAttributes()
        {
            var asm = typeof(ReflectionUtilityTests.DummyTestClass).Assembly;

            var attribs = this.reflectionOperations.GetCustomAttributes(asm, typeof(ReflectionUtilityTests.DummyAAttribute));

            Assert.IsNotNull(attribs);
            Assert.AreEqual(2, attribs.Length);

            var expectedAttribs = new string[] { "DummyA : a1", "DummyA : a2" };

            CollectionAssert.AreEqual(expectedAttribs, ReflectionUtilityTests.GetAttributeValuePairs(attribs));
        }
Exemplo n.º 3
0
        public void GetCustomAttributesShouldReturnAllAttributes()
        {
            var minfo = typeof(ReflectionUtilityTests.DummyBaseTestClass).GetMethod("DummyVTestMethod1");

            var attribs = this.reflectionOperations.GetCustomAttributes(minfo, false);

            Assert.IsNotNull(attribs);
            Assert.AreEqual(2, attribs.Length);

            var expectedAttribs = new string[] { "DummyA : base", "DummySingleA : base" };

            CollectionAssert.AreEqual(expectedAttribs, ReflectionUtilityTests.GetAttributeValuePairs(attribs));
        }