/// <summary> /// Collects the exported methods with missing tests to excel. /// </summary> /// <param name="decompilerType">The decompiler type.</param> /// <param name="reportDirectory">The report directory.</param> /// <param name="sourceAssembly">The source assembly.</param> /// <param name="testAssembly">The test assembly.</param> /// <param name="excludeSourceTypes">The exclude source types.</param> /// <exception cref="ArgumentNullException">reportDirectory.</exception> public static void CollectExportedMethodsWithMissingTestsToExcel( DecompilerType decompilerType, DirectoryInfo reportDirectory, Assembly sourceAssembly, Assembly testAssembly, List <Type>?excludeSourceTypes = null) { if (reportDirectory == null) { throw new ArgumentNullException(nameof(reportDirectory)); } if (sourceAssembly == null) { throw new ArgumentNullException(nameof(sourceAssembly)); } if (testAssembly == null) { throw new ArgumentNullException(nameof(testAssembly)); } var methodsWithMissingTests = AssemblyTestHelper.CollectExportedMethodsWithMissingTests( decompilerType, sourceAssembly, testAssembly, excludeSourceTypes); TestResultHelper.ToExcelTestResultsFromMethodsWithMissingTests( reportDirectory, sourceAssembly.GetName().Name, methodsWithMissingTests); }
/// <summary> /// Asserts the exported methods with missing tests. /// </summary> /// <param name="decompilerType">The decompiler type.</param> /// <param name="sourceAssembly">The source assembly.</param> /// <param name="testAssembly">The test assembly.</param> /// <param name="excludeSourceTypes">The exclude source types.</param> /// <param name="useFullName">if set to <c>true</c> [use full name].</param> public static void AssertExportedMethodsWithMissingTests( DecompilerType decompilerType, Assembly sourceAssembly, Assembly testAssembly, List <Type>?excludeSourceTypes = null, bool useFullName = false) { if (sourceAssembly == null) { throw new ArgumentNullException(nameof(sourceAssembly)); } if (testAssembly == null) { throw new ArgumentNullException(nameof(testAssembly)); } var methodsWithMissingTests = AssemblyTestHelper.CollectExportedMethodsWithMissingTests( decompilerType, sourceAssembly, testAssembly, excludeSourceTypes); TestResultHelper.AssertOnTestResultsFromMethodsWithMissingTests( sourceAssembly.GetName().Name, methodsWithMissingTests, useFullName); }
/// <summary> /// Asserts the exported methods with missing tests. /// </summary> /// <param name="decompilerType">The decompiler type.</param> /// <param name="sourceType">Type of the source.</param> /// <param name="testType">Type of the test.</param> /// <param name="useFullName">if set to <c>true</c> [use full name].</param> public static void AssertExportedMethodsWithMissingTests( DecompilerType decompilerType, Type sourceType, Type testType, bool useFullName = false) { if (sourceType == null) { throw new ArgumentNullException(nameof(sourceType)); } if (testType == null) { throw new ArgumentNullException(nameof(testType)); } var methodsWithMissingTests = AssemblyTestHelper.CollectExportedMethodsWithMissingTests( decompilerType, sourceType, testType); TestResultHelper.AssertOnTestResultsFromMethodsWithMissingTests( sourceType.Assembly.GetName().Name, methodsWithMissingTests, useFullName); }
/// <summary> /// Asserts the exported types with missing comments. /// </summary> /// <param name="assembly">The assembly.</param> /// <param name="excludeTypes">The exclude types.</param> public static void AssertExportedTypesWithMissingComments( Assembly assembly, List <Type>?excludeTypes = null) { if (assembly == null) { throw new ArgumentNullException(nameof(assembly)); } // Due to some build issue with GenerateDocumentationFile=true and xml-file location, this hack is made for now. if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { return; } var typesWithMissingCommentsGroups = DocumentationHelper.CollectExportedTypesWithMissingCommentsFromAssembly( assembly, excludeTypes) .OrderBy(x => x.Type.FullName) .GroupBy(x => x.Type.BeautifyName(true), StringComparer.Ordinal) .ToArray(); var testResults = new List <TestResult> { new TestResult($"Assembly: {assembly.GetName()}"), }; testResults.AddRange(typesWithMissingCommentsGroups.Select(item => new TestResult(false, 1, $"Type: {item.Key}"))); TestResultHelper.AssertOnTestResults(testResults); }
/// <summary> /// Asserts the exported types with missing comments. /// </summary> /// <param name="assembly">The assembly.</param> /// <param name="excludeTypes">The exclude types.</param> public static void AssertExportedTypesWithMissingComments( Assembly assembly, List <Type>?excludeTypes = null) { if (assembly == null) { throw new ArgumentNullException(nameof(assembly)); } var typesWithMissingCommentsGroups = DocumentationHelper.CollectExportedTypesWithMissingCommentsFromAssembly( assembly, excludeTypes) .OrderBy(x => x.Type.FullName) .GroupBy(x => x.Type.BeautifyName(true)) .ToArray(); var testResults = new List <TestResult> { new TestResult($"Assembly: {assembly.GetName()}"), }; testResults.AddRange(typesWithMissingCommentsGroups.Select(item => new TestResult(false, 1, $"Type: {item.Key}"))); TestResultHelper.AssertOnTestResults(testResults); }
/// <summary> /// Asserts the exported type with missing comments. /// </summary> /// <param name="type">The type.</param> public static void AssertExportedTypeWithMissingComments(Type type) { var typeComments = DocumentationHelper.CollectExportedTypeWithCommentsFromType(type); var testResults = new List <TestResult>(); if (typeComments != null && !typeComments.HasComments) { testResults.Add(new TestResult(true, 0, $"Type: {typeComments.Type.BeautifyTypeName(true)}")); } TestResultHelper.AssertOnTestResults(testResults); }
/// <summary> /// Asserts the exported types with wrong definitions. /// </summary> /// <param name="assembly">The assembly.</param> /// <param name="excludeTypes">The exclude types.</param> /// <param name="useFullName">if set to <c>true</c> [use full name].</param> public static void AssertExportedTypesWithWrongDefinitions( Assembly assembly, List <Type>?excludeTypes = null, bool useFullName = false) { if (assembly == null) { throw new ArgumentNullException(nameof(assembly)); } var methodsWithWrongNaming = AssemblyAnalyzerHelper.CollectExportedMethodsWithWrongNaming( assembly, excludeTypes); TestResultHelper.AssertOnTestResultsFromMethodsWithWrongDefinitions( assembly.GetName().Name, methodsWithWrongNaming, useFullName); }