コード例 #1
0
        public void TestFieldProtected()
        {
            //direct
            FieldInfo f = IntrospectionUtil.FindField(typeof(ClassFixtureA), "protectedA", typeof(int), true, false);

            Assert.AreEqual(f, protectedAField);

            //inheritance
            f = IntrospectionUtil.FindField(typeof(ClassFixtureB), "protectedA", typeof(int), true, false);
            Assert.AreEqual(f, protectedAField);
        }
コード例 #2
0
        public void TestFieldDefault()
        {
            //direct
            FieldInfo f = IntrospectionUtil.FindField(typeof(ClassFixtureA), "internalA", typeof(int), true, false);

            Assert.AreEqual(f, defaultAField);

            //inheritance
            f = IntrospectionUtil.FindField(typeof(ClassFixtureB), "internalA", typeof(int), true, false);
            Assert.AreEqual(f, defaultAField);
        }
コード例 #3
0
        public void TestFieldPrivate()
        {
            //direct
            FieldInfo f = IntrospectionUtil.FindField(typeof(ClassFixtureA), "privateA", typeof(int), true, false);

            Assert.AreEqual(privateAField, f);

            try
            {
                //inheritance
                IntrospectionUtil.FindField(typeof(ClassFixtureB), "privateB", typeof(int), true, false);
                Assert.Fail("Private fields should not be inherited");
            }
            catch (ArgumentException)
            {
            }
        }