Пример #1
0
        private void processMethod(Tester.TestAuditInfoType typeInfo, MethodInfo method)
        {
            if (method != null)
            {
                var methodAttribute = method.GetCustomAttribute <TestedAttribute>(false);
                if (methodAttribute != null)
                {
                    var info = getAuditInfo(method, methodAttribute);
                    switch (methodAttribute.Status)
                    {
                    case TestedAttribute.TestStatus.Tested:
                        typeInfo.TestedFunctions.Add(info);
                        break;

                    case TestedAttribute.TestStatus.Untested:
                        typeInfo.UntestedFunctions.Add(info);
                        break;

                    case TestedAttribute.TestStatus.Ignored:
                        typeInfo.IgnoredFunctions.Add(info);
                        break;
                    }
                }
                else
                {
                    typeInfo.UndocumentedFunctions.Add(new Tester.TestAuditInfo
                    {
                        Name            = method.Name,
                        Status          = TestedAttribute.TestStatus.Untested,
                        TestDescription = "Undocumented"
                    });
                }
            }
        }
Пример #2
0
        private Tester.TestAuditInfoType ProcessType(Type type, TestedAttribute typeAttribute)
        {
            Tester.TestAuditInfoType typeInfo = null;
            if (typeAttribute != null)
            {
                typeInfo = new Tester.TestAuditInfoType()
                {
                    Name            = type.Name,
                    TestReference   = typeAttribute.TestReference,
                    TestDescription = typeAttribute.TestDescription,
                    Status          = typeAttribute.Status,
                    ObjectType      = type,
                };

                var methods = type.GetMethods().ToList();
                foreach (var method in methods)
                {
                    if (method.IsPublic && !method.IsSpecialName && method.IsHideBySig)
                    {
                        // process method if it is public and not a property
                        processMethod(typeInfo, method);
                    }
                }
            }
            else
            {
                // undocumented, create info as needed
                typeInfo = new Tester.TestAuditInfoType()
                {
                    Name            = type.Name,
                    TestReference   = "NA",
                    TestDescription = "No Test Attribute Defined",
                    Status          = TestedAttribute.TestStatus.Untested,
                    ObjectType      = type,
                };
            }
            return(typeInfo);
        }