Exemple #1
0
        ///// <summary>
        ///// Gets a count of test cases that would be run using
        ///// the specified filter.
        ///// </summary>
        ///// <param name="filter"></param>
        ///// <returns></returns>
        //public virtual int CountTestCases(TestFilter filter)
        //{
        //    if (filter.Pass(this))
        //        return 1;

        //    return 0;
        //}

        /// <summary>
        /// Modify a newly constructed test by applying any of NUnit's common
        /// attributes, based on a supplied ICustomAttributeProvider, which is
        /// usually the reflection element from which the test was constructed,
        /// but may not be in some instances.
        /// </summary>
        /// <param name="provider">An object implementing ICustomAttributeProvider</param>
        public void ApplyCommonAttributes(ICustomAttributeProvider provider)
        {
            foreach (Attribute attribute in provider.GetCustomAttributes(typeof(NUnitAttribute), true))
            {
                IApplyToTest iApply = attribute as IApplyToTest;
                if (iApply != null)
                {
                    iApply.ApplyToTest(this);
                }
            }
        }
Exemple #2
0
        ///// <summary>
        ///// Gets a count of test cases that would be run using
        ///// the specified filter.
        ///// </summary>
        ///// <param name="filter"></param>
        ///// <returns></returns>
        //public virtual int CountTestCases(TestFilter filter)
        //{
        //    if (filter.Pass(this))
        //        return 1;

        //    return 0;
        //}

        /// <summary>
        /// Modify a newly constructed test by applying any of NUnit's common
        /// attributes, based on a supplied ICustomAttributeProvider, which is
        /// usually the reflection element from which the test was constructed,
        /// but may not be in some instances. The attributes retrieved are
        /// saved for use in subsequent operations.
        /// </summary>
        /// <param name="provider">An object implementing ICustomAttributeProvider</param>
        public void ApplyAttributesToTest(ICustomAttributeProvider provider)
        {
            this.attributes = (NUnitAttribute[])provider.GetCustomAttributes(typeof(NUnitAttribute), true);

            foreach (Attribute attribute in this.attributes)
            {
                IApplyToTest iApply = attribute as IApplyToTest;
                if (iApply != null)
                {
                    iApply.ApplyToTest(this);
                }
            }
        }