コード例 #1
0
        public static IEnumerable <TestMethod> TestMethods(this VBComponent component)
        {
            IHostApplication hostApp = component.VBE.HostApplication();

            if (component.Type == vbext_ComponentType.vbext_ct_StdModule && component.CodeModule.HasAttribute <TestModuleAttribute>())
            {
                return(component.GetMembers().Where(member => IsTestMethod(member))
                       .Select(member => new TestMethod(component.Collection.Parent.Name, component.Name, member.Name, hostApp)));
            }

            return(new List <TestMethod>());
        }
コード例 #2
0
        /// <summary>
        /// Runs all methods with specified attribute.
        /// </summary>
        /// <typeparam name="TAttribute"></typeparam>
        /// <param name="component"></param>
        /// <remarks>
        /// Order of execution cannot be garanteed.
        /// </remarks>
        public static void RunMethodsWithAttribute <TAttribute>(this VBComponent component)
            where TAttribute : MemberAttributeBase, new()
        {
            var hostApp = component.VBE.HostApplication();
            var methods = component.GetMembers(vbext_ProcKind.vbext_pk_Proc)
                          .Where(member => member.HasAttribute <TAttribute>());

            foreach (var method in methods)
            {
                hostApp.Run(method.QualifiedMemberName);
            }
        }
コード例 #3
0
        public static IEnumerable <TestMethod> TestMethods(this VBComponent component)
        {
            if (component.Type == vbext_ComponentType.vbext_ct_StdModule &&
                component.CodeModule.HasAttribute <TestModuleAttribute>())
            {
                return(component.GetMembers()
                       .Where(IsTestMethod)
                       .Select(member => new TestMethod(member.QualifiedMemberName, component.VBE)));
            }

            return(new List <TestMethod>());
        }