Example #1
0
        /// <summary>
        /// Decorates a test class instance with the unit test framework's 
        /// specific test context capability, if supported.
        /// </summary>
        /// <param name="instance">Instance to decorate.</param>
        public void DecorateInstance(object instance)
        {
            if (instance == null)
            {
                return;
            }

            Type t = instance.GetType();
            PropertyInfo pi = t.GetProperty(ContextPropertyName, BindingFlags.Public | BindingFlags.Instance);
            if (pi != null && pi.CanWrite)
            {
                try
                {
                    UnitTestContext utc = new UnitTestContext(this);
                    pi.SetValue(instance, utc, null);
                }
                finally
                {
                }
            }
        }
        /// <summary>
        /// Decorates a test class instance with the unit test framework's
        /// specific test context capability, if supported.
        /// </summary>
        /// <param name="instance">Instance to decorate.</param>
        public void DecorateInstance(object instance)
        {
            if (instance == null)
            {
                return;
            }

            Type         t  = instance.GetType();
            PropertyInfo pi = t.GetProperty(ContextPropertyName, BindingFlags.Public | BindingFlags.Instance);

            if (pi != null && pi.CanWrite)
            {
                try
                {
                    UnitTestContext utc = new UnitTestContext(this);
                    pi.SetValue(instance, utc, null);
                }
                finally
                {
                }
            }
        }